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..2d7bf679f 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-6ba9b1b34b3995136fce37ca4bfa7ec253213680ef1d49d74960f55d22fde5dc.yml +openapi_spec_hash: 56d69d79bef9db11216cf8764106040f +config_hash: c01c1191b1cd696c7ca855ff6d28a8df diff --git a/CHANGELOG.md b/CHANGELOG.md index 15283c170..4e815844e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,102 @@ # Changelog +## 0.2.0 (2026-05-13) + +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 ([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..74abc308c 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,720 +734,4273 @@ 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"], + 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, + }; + + 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, + 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 = + [ + 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", - Filters = + 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() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + HideZeroAmountTiers = true, + Prorate = true, }, - 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", }; + value.Validate(); + } - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + [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 FieldRoundtripThroughSerialization_Works() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + PackageSize = 0, + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - 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", }; + value.Validate(); + } - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Adjustment expectedAdjustment = new Models::NewPercentageDiscount() + [Fact] + public void NewPlanPackageWithAllocationValidationWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanUnitWithPercentValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanUnitWithPercentPrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - PlanPhaseOrder = 0, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanMatrixWithAllocationValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanMatrixWithAllocationPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = 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, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void TieredWithProrationValidationWorks() { - var model = new AddAdjustment + Price value = new TieredWithProration() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new AddAdjustment - { - Adjustment = new Models::NewPercentageDiscount() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - - 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() + Currency = "currency", + DimensionalPriceConfiguration = 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, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - - PlanPhaseOrder = null, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 AdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void NewPlanUnitWithProrationValidationWorks() { - Adjustment value = new Models::NewPercentageDiscount() + Price value = new Models::NewPlanUnitWithProrationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void NewPlanGroupedAllocationValidationWorks() { - Adjustment value = new Models::NewUsageDiscount() + Price value = new Models::NewPlanGroupedAllocationPrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanBulkWithProrationValidationWorks() { - Adjustment value = new Models::NewAmountDiscount() + Price value = new Models::NewPlanBulkWithProrationPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedWithProratedMinimumValidationWorks() { - Adjustment value = new Models::NewMinimum() + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedWithMeteredMinimumValidationWorks() { - Adjustment value = new Models::NewMaximum() + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void GroupedWithMinMaxThresholdsValidationWorks() { - Adjustment value = new Models::NewPercentageDiscount() + Price value = new GroupedWithMinMaxThresholds() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - Adjustment value = new Models::NewUsageDiscount() + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedTieredPackageValidationWorks() { - Adjustment value = new Models::NewAmountDiscount() + Price value = new Models::NewPlanGroupedTieredPackagePrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanMaxGroupTieredPackageValidationWorks() { - Adjustment value = new Models::NewMinimum() + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanScalableMatrixWithUnitPricingValidationWorks() { - Adjustment value = new Models::NewMaximum() + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class AddPriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - var model = new AddPrice + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - AllocationPrice = new() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", }, - 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, }, - }; - - 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; - Price expectedPrice = new Models::NewPlanUnitPrice() + value.Validate(); + } + + [Fact] + public void NewPlanCumulativeGroupedBulkValidationWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1268,199 +5029,131 @@ 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); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CumulativeGroupedAllocationValidationWorks() { - var model = new AddPrice + Price value = new CumulativeGroupedAllocation() { - AllocationPrice = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = 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", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, ModelBase.SerializerOptions); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void DailyCreditAllowanceValidationWorks() { - var model = new AddPrice + Price value = new DailyCreditAllowance() { - AllocationPrice = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = 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", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, }, - }; - - 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() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "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; - Price expectedPrice = new Models::NewPlanUnitPrice() + value.Validate(); + } + + [Fact] + public void MeteredAllowanceValidationWorks() + { + Price value = new MeteredAllowance() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1489,145 +5182,153 @@ 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(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanMinimumCompositeValidationWorks() { - var model = new AddPrice + Price value = new Models::NewPlanMinimumCompositePrice() { - AllocationPrice = new() + 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() { - 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"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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.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(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void PercentValidationWorks() { - var model = new AddPrice + Price value = new Percent() { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void EventOutputValidationWorks() { - var model = new AddPrice + Price value = new EventOutput() { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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(); + value.Validate(); } -} -public class PriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanUnitSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitPrice() { @@ -1664,14 +5365,18 @@ 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 NewPlanTieredSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPrice() { @@ -1720,14 +5425,18 @@ 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 NewPlanBulkSerializationRoundtripWorks() { Price value = new Models::NewPlanBulkPrice() { @@ -1764,14 +5473,18 @@ 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 BulkWithFiltersSerializationRoundtripWorks() { Price value = new BulkWithFilters() { @@ -1784,7 +5497,7 @@ public void BulkWithFiltersValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -1815,14 +5528,18 @@ 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 NewPlanPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanPackagePrice() { @@ -1859,14 +5576,18 @@ 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 NewPlanMatrixSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixPrice() { @@ -1908,14 +5629,18 @@ 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() { Price value = new Models::NewPlanThresholdTotalAmountPrice() { @@ -1960,14 +5685,18 @@ 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 NewPlanTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPackagePrice() { @@ -2012,14 +5741,18 @@ 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() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredWithMinimumPrice() { @@ -2075,14 +5808,18 @@ 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 NewPlanGroupedTieredSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedTieredPrice() { @@ -2127,14 +5864,18 @@ 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { @@ -2190,14 +5931,18 @@ 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanPackageWithAllocationPrice() { @@ -2239,14 +5984,18 @@ 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 NewPlanUnitWithPercentSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitWithPercentPrice() { @@ -2283,14 +6032,18 @@ 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixWithAllocationPrice() { @@ -2333,14 +6086,18 @@ 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 TieredWithProrationSerializationRoundtripWorks() { Price value = new TieredWithProration() { @@ -2378,14 +6135,18 @@ 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 NewPlanUnitWithProrationSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitWithProrationPrice() { @@ -2422,14 +6183,18 @@ 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 NewPlanGroupedAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedAllocationPrice() { @@ -2471,14 +6236,18 @@ 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 NewPlanBulkWithProrationSerializationRoundtripWorks() { Price value = new Models::NewPlanBulkWithProrationPrice() { @@ -2520,14 +6289,18 @@ 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { @@ -2570,14 +6343,18 @@ 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { @@ -2629,14 +6406,18 @@ 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Price value = new GroupedWithMinMaxThresholds() { @@ -2678,14 +6459,18 @@ 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { @@ -2734,14 +6519,18 @@ 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedTieredPackagePrice() { @@ -2787,14 +6576,18 @@ 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { @@ -2840,14 +6633,18 @@ 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { @@ -2869,6 +6666,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2900,14 +6698,18 @@ 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { @@ -2963,14 +6765,18 @@ 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); } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { @@ -3019,27 +6825,235 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() 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 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", + }; + 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 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() + { + 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", + }; + 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 CumulativeGroupedAllocationValidationWorks() + public void PercentSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new Percent() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3068,20 +7082,29 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void EventOutputSerializationRoundtripWorks() { - Price value = new Minimum() + Price value = new EventOutput() { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -3111,21 +7134,35 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } +} +public class BulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new BulkWithFilters { - 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3155,21 +7192,102 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 PercentValidationWorks() + public void SerializationRoundtrip_Works() { - Price value = new Percent() + var model = new BulkWithFilters { - Cadence = PercentCadence.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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3198,24 +7316,35 @@ public void PercentValidationWorks() 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 EventOutputValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new EventOutput() + var model = new BulkWithFilters { - Cadence = EventOutputCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -3246,22 +7375,112 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string element = JsonSerializer.Serialize(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 NewPlanUnitSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanUnitPrice() + 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() @@ -3290,125 +7509,89 @@ 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); + model.Validate(); } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanTieredPrice() + var model = new BulkWithFilters { - 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, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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")); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Models::NewPlanBulkPrice() + var model = new BulkWithFilters { - 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() + 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 = 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); + model.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new BulkWithFilters() + var model = new BulkWithFilters { BulkWithFiltersConfig = new() { @@ -3419,56 +7602,110 @@ public void BulkWithFiltersSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + 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() + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - 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 = 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanPackagePrice() + var model = new BulkWithFilters { - Cadence = Models::NewPlanPackagePriceCadence.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::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3497,379 +7734,467 @@ 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); + 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 NewPlanMatrixSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new Models::NewPlanMatrixPrice() + var model = new Tier { - 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", + + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new Tier { - 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); + model.Validate(); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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, - }, - 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>( + 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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = + 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() { 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", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class TieredWithProrationTest : TestBase +{ [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3898,78 +8223,91 @@ 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); - } - [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() - { - Price value = new Models::NewPlanUnitWithPercentPrice() + 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::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() + 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(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, deserialized); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.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", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3998,19 +8336,24 @@ 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); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new TieredWithProration() + var model = new TieredWithProration { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", @@ -4046,25 +8389,101 @@ 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 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.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() @@ -4093,30 +8512,173 @@ 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); + 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4145,367 +8707,355 @@ 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); + + 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanBulkWithProrationPrice() + 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 { - 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", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new TieredWithProrationConfigTier { - 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", + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new TieredWithProrationConfigTier { - 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", + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new GroupedWithMinMaxThresholds() + var model = new TieredWithProrationConfigTier { - 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", + 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); + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } +} +public class TieredWithProrationConversionRateConfigTest : TestBase +{ [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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() + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4535,41 +9085,104 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + 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, 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = 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", + 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() @@ -4598,44 +9211,35 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + 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() @@ -4664,36 +9268,113 @@ 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); + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4723,27 +9404,190 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new CumulativeGroupedAllocation() + var model = new GroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -4775,223 +9619,283 @@ 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); + + 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 MinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Minimum() + var model = new GroupedWithMinMaxThresholdsConfig { - 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", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + 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 NewPlanMinimumCompositeSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new GroupedWithMinMaxThresholdsConfig { - 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", + 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", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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() + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() { - 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() + 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 BulkWithFiltersTest : TestBase +public class CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5022,22 +9926,24 @@ 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 = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5047,7 +9953,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5068,11 +9974,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( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5087,6 +9997,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5101,18 +10012,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5143,12 +10052,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 ); @@ -5159,18 +10069,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5201,29 +10109,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); - BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5233,7 +10143,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5254,11 +10164,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( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -5276,6 +10190,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5290,18 +10205,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5332,6 +10245,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5342,18 +10256,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5380,6 +10292,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5389,18 +10303,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5411,18 +10323,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5437,6 +10347,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5463,6 +10374,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -5472,18 +10385,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5498,197 +10409,172 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class BulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new CumulativeGroupedAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - - 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" }, - ], - }; + CumulativeGroupedAllocation copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class FilterTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [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) { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.NotNull(deserialized); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class TierTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -5696,184 +10582,113 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new 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 + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - 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 Tier + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", 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 - ); + CumulativeGroupedAllocationConfig copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class ConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + CumulativeGroupedAllocationConversionRateConfig 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, - }, - ] - ), - }; + 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() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + 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 deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -5881,43 +10696,50 @@ 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, - }, - ] - ), - }; + 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 deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class TieredWithProrationTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = 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() @@ -5946,18 +10768,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 = + 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("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_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() @@ -5966,7 +10794,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5987,14 +10815,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(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); @@ -6006,6 +10835,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10850,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = 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() @@ -6056,12 +10891,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 +10908,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = 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() @@ -6108,25 +10949,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 = + 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("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_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() @@ -6135,7 +10982,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6156,14 +11003,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(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); @@ -6178,6 +11026,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11041,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = 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() @@ -6228,6 +11082,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 +11093,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = 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" }] - ), }; Assert.Null(model.BillableMetricID); @@ -6270,6 +11130,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11141,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = 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" }] - ), }; model.Validate(); @@ -6295,14 +11162,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = 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 = null, BilledInAdvance = null, @@ -6315,6 +11187,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6341,6 +11214,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11225,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = 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 = null, BilledInAdvance = null, @@ -6370,34 +11250,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 TieredWithProrationCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : 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(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 ); @@ -6407,19 +11342,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(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>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -6430,12 +11365,12 @@ public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) [Fact] public void InvalidEnumSerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -6444,38 +11379,58 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6486,71 +11441,104 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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( + var deserialized = 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]); } } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new DailyCreditAllowanceConfig { - 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 expectedTierLowerBound = "tier_lower_bound"; + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + 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); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6561,56 +11549,63 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { 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 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); } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig 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() { - TieredWithProrationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6631,13 +11626,14 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig 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 ); @@ -6648,7 +11644,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6664,7 +11660,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6673,22 +11669,24 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6718,23 +11716,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 = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig 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; @@ -6744,7 +11742,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6765,15 +11763,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( - 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); @@ -6787,6 +11783,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11798,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6841,12 +11840,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 +11857,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6897,30 +11899,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 = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig 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; @@ -6930,7 +11932,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6951,15 +11953,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( - 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); @@ -6976,6 +11976,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11991,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7030,6 +12033,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 +12044,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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", }; @@ -7076,6 +12082,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12093,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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", }; @@ -7105,17 +12115,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7129,6 +12141,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7155,6 +12168,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12179,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7188,34 +12205,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 GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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(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 ); @@ -7225,21 +12298,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(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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7247,56 +12321,65 @@ 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 MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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 GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 ); @@ -7307,97 +12390,189 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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( + var deserialized = 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 GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + MeteredAllowanceConversionRateConfig 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, - }, - ] - ), - }; + 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() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + 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 - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7405,49 +12580,41 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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 - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7476,24 +12643,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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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() @@ -7502,7 +12661,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7523,17 +12682,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( - 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); @@ -7545,6 +12702,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7559,18 +12717,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7599,15 +12751,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); } @@ -7615,18 +12765,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7655,31 +12799,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 = - 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" - ); + 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() @@ -7688,7 +12824,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7709,17 +12845,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( - 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); @@ -7734,6 +12868,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7748,18 +12883,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7788,6 +12917,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7798,18 +12928,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -7834,6 +12958,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7843,18 +12969,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -7863,18 +12983,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7887,6 +13001,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7913,6 +13028,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7922,18 +13039,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7946,34 +13057,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 CumulativeGroupedAllocationCadenceTest : TestBase +public class PercentCadenceTest : 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(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 ); @@ -7983,21 +13142,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(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); } @@ -8005,56 +13165,39 @@ 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 PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new PercentConfig { 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 CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8063,142 +13206,307 @@ public void SerializationRoundtrip_Works() } [Fact] - public void FieldRoundtripThroughSerialization_Works() + 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() { - var model = new CumulativeGroupedAllocationConfig + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - 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 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void TieredSerializationRoundtripWorks() { - var model = new CumulativeGroupedAllocationConfig + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::ConversionRateType.Tiered, + 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class EventOutputTest : TestBase { [Fact] - public void UnitValidationWorks() + public void FieldRoundtrip_Works() { - CumulativeGroupedAllocationConversionRateConfig 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() - { - CumulativeGroupedAllocationConversionRateConfig 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() - { - CumulativeGroupedAllocationConversionRateConfig 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() { - CumulativeGroupedAllocationConversionRateConfig 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 MinimumTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8228,18 +13536,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 = MinimumCadence.Annual; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = 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() { - MinimumAmount = "minimum_amount", - Prorated = true, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8249,7 +13566,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8270,44 +13587,54 @@ 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(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(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); + 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(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(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { - var model = new Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8337,24 +13664,187 @@ 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); + model.Validate(); + } - Assert.Equal(model, deserialized); + [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 FieldRoundtripThroughSerialization_Works() + 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 Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8384,354 +13874,436 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + 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(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() + 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 { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + 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 { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::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 EventOutputConfig { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - 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 + string element = JsonSerializer.Serialize(model, 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.NotNull(deserialized); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + 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 Minimum + var model = new EventOutputConfig { - 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", + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Minimum + var model = new EventOutputConfig { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitValidationWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredValidationWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } - 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, + [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.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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 TieredSerializationRoundtripWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - 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, + ConversionRateType = Models::ConversionRateType.Tiered, + 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 MinimumCadenceTest : TestBase +public class RemoveAdjustmentTest : 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) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + 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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); + + 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", - Assert.Equal(value, deserialized); + PlanPhaseOrder = null, + }; + + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - Assert.Equal(value, deserialized); + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); } } -public class MinimumConfigTest : TestBase +public class RemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + 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 ); @@ -8742,304 +14314,178 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new RemovePrice { PriceID = "price_id" }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new RemovePrice { PriceID = "price_id" }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MinimumConfig + var model = new RemovePrice { - MinimumAmount = "minimum_amount", + PriceID = "price_id", - // Null should be interpreted as omitted for these properties - Prorated = null, + PlanPhaseOrder = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new RemovePrice { - MinimumAmount = "minimum_amount", + PriceID = "price_id", - // Null should be interpreted as omitted for these properties - Prorated = null, + PlanPhaseOrder = null, }; model.Validate(); } -} - -public class MinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } [Fact] - public void UnitSerializationRoundtripWorks() + public void CopyConstructor_Works() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - [Fact] - public void TieredSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + RemovePrice copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class PercentTest : TestBase +public class ReplaceAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - 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() + 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, }; - 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() + 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, 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)); + 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 Percent + var model = new ReplaceAdjustment { - 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() + 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); } @@ -9047,157 +14493,94 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - 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() + 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 = 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() + 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.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)); + 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 Percent + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["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(); @@ -9206,51 +14589,61 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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 Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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(); @@ -9259,246 +14652,360 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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 Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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, }; 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 PercentCadenceTest : TestBase +public class ReplaceAdjustmentAdjustmentTest : TestBase { - [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void Validation_Works(PercentCadence rawValue) + [Fact] + public void NewPercentageDiscountValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + 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 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) + public void NewUsageDiscountValidationWorks() { - // force 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); + 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 InvalidEnumSerializationRoundtrip_Works() + public void NewAmountDiscountValidationWorks() { - 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); + 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(); } -} -public class PercentConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewMinimumValidationWorks() { - var model = new PercentConfig { Percent = 0 }; - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, model.Percent); + 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 SerializationRoundtrip_Works() + public void NewMaximumValidationWorks() { - var model = new PercentConfig { Percent = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + 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 FieldRoundtripThroughSerialization_Works() + public void NewPercentageDiscountSerializationRoundtripWorks() { - var model = new PercentConfig { Percent = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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.NotNull(deserialized); - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, deserialized.Percent); - } - - [Fact] - public void Validation_Works() - { - var model = new PercentConfig { Percent = 0 }; - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class PercentConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - PercentConversionRateConfig 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() { - PercentConversionRateConfig 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() { - PercentConversionRateConfig 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 ); @@ -9507,24 +15014,30 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewMaximumSerializationRoundtripWorks() { - PercentConversionRateConfig 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 ); @@ -9533,22 +15046,213 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class ReplacePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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() @@ -9577,93 +15281,322 @@ 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", - }; - 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() + 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 { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = 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", + 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 expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::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 ReplacePrice { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new EventOutput + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = new() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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() @@ -9692,33 +15625,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 EventOutput + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -9747,133 +15665,139 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + 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 EventOutput + var model = new ReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + LicenseAllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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", }, - 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", }; model.Validate(); @@ -9882,62 +15806,22 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new ReplacePrice { 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.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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.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 EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; model.Validate(); } @@ -9945,194 +15829,365 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [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, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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 EventOutput + var model = new ReplacePrice { - Cadence = EventOutputCadence.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, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, }; - model.Validate(); - } -} - -public class EventOutputCadenceTest : TestBase -{ - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void Validation_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + 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")); } - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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); + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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"; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "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(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.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 ); @@ -10143,194 +16198,543 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.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 Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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 }, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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")); - } + 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 }, - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - UnitRatingKey = "x", + 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 }, - DefaultUnitRate = null, - GroupingKey = 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.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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(); + ReplacePriceLicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputConversionRateConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceCadenceTest : TestBase { - [Fact] - public void UnitValidationWorks() + [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) { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void TieredValidationWorks() + public void InvalidEnumValidationThrows_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void UnitSerializationRoundtripWorks() + [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) { - 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 - ); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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 - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid 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 ReplacePriceLicenseAllocationPriceLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -10338,26 +16742,39 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -10365,16 +16782,24 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } @@ -10382,855 +16807,1179 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemoveAdjustment + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - AdjustmentID = "adjustment_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new RemoveAdjustment + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - AdjustmentID = "adjustment_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; model.Validate(); } -} -public class RemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + ReplacePriceLicenseAllocationPriceLicenseAllocation copied = new(model); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +public class ReplacePriceLicenseAllocationPriceModelTypeTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceModelType rawValue) { - 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); + // 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 RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + 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 expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + 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 RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var value = 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 ReplacePriceLicenseAllocationPriceConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void UnitValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitSerializationRoundtripWorks() { - var model = new RemovePrice { PriceID = "price_id" }; + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredSerializationRoundtripWorks() { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; + 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 + ); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanUnitValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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(); + value.Validate(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanTieredValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + 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 = 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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 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 NewPlanBulkValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanBulkPrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 BulkWithFiltersValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - Adjustment = new Models::NewPercentageDiscount() + BulkWithFiltersConfig = new() { - 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() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - 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"], + 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", - 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 NewPlanPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanMatrixValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = 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, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanThresholdTotalAmountValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorate = true, }, - ReplacesAdjustmentID = "replaces_adjustment_id", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + 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 = 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 NewPlanTieredWithMinimumValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - 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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = 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() + public void NewPlanGroupedTieredValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanTieredPackageWithMinimumValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanPackageWithAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanUnitWithPercentValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void NewPlanMatrixWithAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanUnitWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void NewPlanGroupedAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanBulkWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = 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", + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, }, - }; - - 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() + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithMeteredMinimumValidationWorks() + { + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11259,206 +18008,139 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = 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", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Dimension = "dimension", + UnitAmounts = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, }, - }; - - 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() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "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() + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredPackageValidationWorks() + { + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11487,159 +18169,158 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class ReplacePricePriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -11668,6 +18349,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11675,27 +18357,27 @@ public void NewPlanUnitValidationWorks() } [Fact] - public void NewPlanTieredValidationWorks() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Tiers = + DimensionValues = [ new() { - FirstUnit = 0, + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - LastUnit = 0, }, ], - Prorated = true, + Group = "group", }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11724,6 +18406,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11731,14 +18414,19 @@ public void NewPlanTieredValidationWorks() } [Fact] - public void NewPlanBulkValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11768,6 +18456,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11775,20 +18464,19 @@ public void NewPlanBulkValidationWorks() } [Fact] - public void BulkWithFiltersValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - BulkWithFiltersConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -11819,6 +18507,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11826,15 +18515,22 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewPlanPackageValidationWorks() + public void MeteredAllowanceValidationWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11863,6 +18559,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11870,19 +18567,14 @@ public void NewPlanPackageValidationWorks() } [Fact] - public void NewPlanMatrixValidationWorks() + public void NewPlanMinimumCompositeValidationWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11912,6 +18604,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11919,23 +18612,14 @@ public void NewPlanMatrixValidationWorks() } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void PercentValidationWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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, - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11964,6 +18648,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11971,23 +18656,19 @@ public void NewPlanThresholdTotalAmountValidationWorks() } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void EventOutputValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12016,6 +18697,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12023,34 +18705,15 @@ public void NewPlanTieredPackageValidationWorks() } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + ModelType = Models::NewPlanUnitPriceModelType.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, - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12079,30 +18742,41 @@ 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 NewPlanTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - GroupingKey = "x", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12131,41 +18805,29 @@ 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 NewPlanBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanBulkPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, 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 +18856,36 @@ 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 BulkWithFiltersSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -12243,22 +18914,29 @@ 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 NewPlanPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = Models::NewPlanPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12287,27 +18965,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 NewPlanMatrixSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = Models::NewPlanMatrixPriceCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12337,23 +19021,37 @@ 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12382,22 +19080,37 @@ 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 NewPlanTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12426,27 +19139,48 @@ 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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() @@ -12475,26 +19209,36 @@ 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 NewPlanGroupedTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - BulkWithProrationConfig = new( + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12524,28 +19268,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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -12574,37 +19338,34 @@ 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - 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::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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() @@ -12633,27 +19394,29 @@ 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 NewPlanUnitWithPercentSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -12682,33 +19445,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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + MatrixWithAllocationConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12738,31 +19502,30 @@ 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 TieredWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - 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" }, - ], - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12791,31 +19554,29 @@ 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 NewPlanUnitWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanUnitWithProrationPriceCadence.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, + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12844,38 +19605,34 @@ 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 NewPlanGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = 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", + 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() @@ -12904,41 +19661,34 @@ 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 NewPlanBulkWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.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::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, 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() @@ -12967,33 +19717,34 @@ 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); } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13023,26 +19774,43 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() 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 CumulativeGroupedAllocationValidationWorks() + public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + 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, @@ -13072,20 +19840,33 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.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, @@ -13115,21 +19896,40 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + 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, @@ -13159,21 +19959,38 @@ public void NewPlanMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = ReplacePricePricePercentCadence.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::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13202,25 +20019,37 @@ public void PercentValidationWorks() 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 EventOutputValidationWorks() + public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13250,22 +20079,46 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -13294,6 +20147,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13307,26 +20161,33 @@ public void NewPlanUnitSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - TieredConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - Prorated = true, + 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, @@ -13356,6 +20217,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13369,14 +20231,26 @@ public void NewPlanTieredSerializationRoundtripWorks() } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.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::NewPlanBulkPriceModelType.Bulk, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13406,6 +20280,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13419,20 +20294,18 @@ public void NewPlanBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - BulkWithFiltersConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -13463,6 +20336,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13476,15 +20350,21 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + 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", - ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13513,6 +20393,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13526,19 +20407,21 @@ public void NewPlanPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MeteredAllowanceConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13568,6 +20451,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13581,23 +20465,15 @@ public void NewPlanMatrixSerializationRoundtripWorks() } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, 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() @@ -13626,6 +20502,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13639,23 +20516,14 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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" }, - ], - }, + Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13684,6 +20552,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13697,34 +20566,19 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13753,6 +20607,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13764,24 +20619,26 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", + 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" }, ], }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13811,47 +20668,103 @@ 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); + 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + BulkWithFiltersConfig = new() { - PackageSize = 0, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, + 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() @@ -13880,33 +20793,37 @@ 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, + + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -13935,28 +20852,113 @@ 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( + + 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); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.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", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13985,135 +20987,203 @@ 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); + model.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], 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" }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - ConversionRateType = Models::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 = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.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", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14142,958 +21212,539 @@ 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); + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - 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, - }, - 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" }, + ], + }; + + 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", }; - 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 CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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", + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void MinimumSerializationRoundtripWorks() + [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) { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_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() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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 PercentSerializationRoundtripWorks() + public void UnitValidationWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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 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() + 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 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 +21773,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 +21793,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 +21814,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 +21834,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +21844,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 +21885,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 +21902,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 +21938,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 +21965,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 +21986,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 +22009,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22024,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 +22060,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 +22071,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 +22103,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22114,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 +22130,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 +22150,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15565,6 +22177,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22186,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 +22371,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 +22526,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16026,7 +22547,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16034,7 +22555,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16045,7 +22566,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16062,7 +22583,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16071,19 +22592,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 +22637,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 +22665,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 +22686,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 +22709,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +22724,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 +22764,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 +22781,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 +22821,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 +22856,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 +22877,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 +22903,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22918,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 +22958,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 +22969,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 +23005,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23016,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 +23036,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 +23060,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16505,6 +23087,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23098,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 +23122,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 +23204,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 +23212,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 +23237,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 +23299,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 +23379,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16796,7 +23400,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16804,7 +23408,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16815,7 +23419,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16832,7 +23436,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16841,20 +23445,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 +23490,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 +23518,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 +23539,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 +23562,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +23577,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 +23617,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 +23634,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 +23674,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 +23709,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 +23730,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 +23756,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +23771,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 +23811,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 +23822,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 +23858,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23869,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 +23889,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 +23913,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17325,6 +23940,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23951,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 +23975,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 +24057,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 +24065,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 +24090,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 +24153,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 +24232,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17563,7 +24253,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17571,7 +24261,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17582,7 +24272,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17599,7 +24289,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17608,20 +24298,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 +24344,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 +24371,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 +24392,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 +24412,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +24427,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 +24468,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 +24485,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 +24526,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 +24560,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 +24581,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 +24604,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +24619,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 +24660,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 +24671,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 +24708,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24719,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 +24740,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 +24765,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18092,6 +24792,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24803,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 +24911,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 +24919,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 +24942,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 +25135,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 +25206,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18330,7 +25227,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18338,7 +25235,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18349,7 +25246,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18366,7 +25263,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18375,16 +25272,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 +25319,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 +25347,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 +25368,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 +25388,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25403,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 +25445,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 +25462,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 +25504,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 +25539,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 +25560,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 +25583,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25598,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 +25640,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 +25651,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 +25689,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25700,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 +25722,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 +25748,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18801,6 +25775,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25786,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 +25812,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 +25926,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 +25994,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 +26046,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 +26077,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 +26149,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19056,17 +26170,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 +26189,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19090,10 +26205,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 +26254,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 +26294,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 +26314,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26363,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 +26414,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 +26461,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 +26484,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26533,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 +26574,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26617,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19517,6 +26644,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26673,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 +26843,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 +26980,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 +27025,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 +27045,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +27099,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 +27155,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 +27207,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 +27230,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +27284,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 +27330,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27383,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20212,6 +27410,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27444,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 +27697,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..5dca26e76 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,4278 @@ 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() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + HideZeroAmountTiers = true, + Prorate = true, }, - 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", }; + value.Validate(); + } - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + [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 FieldRoundtripThroughSerialization_Works() + public void NewPlanTieredPackageWithMinimumValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + PackageSize = 0, + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, }, - 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", }; + value.Validate(); + } - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - Adjustment expectedAdjustment = new Models::NewPercentageDiscount() + [Fact] + public void NewPlanPackageWithAllocationValidationWorks() + { + Price value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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", }; - long expectedPlanPhaseOrder = 0; - - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanUnitWithPercentValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanUnitWithPercentPrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - PlanPhaseOrder = 0, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanMatrixWithAllocationValidationWorks() { - var model = new AddAdjustment + Price value = new Models::NewPlanMatrixWithAllocationPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = 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, + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void TieredWithProrationValidationWorks() { - var model = new AddAdjustment + Price value = new TieredWithProration() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new AddAdjustment - { - Adjustment = new Models::NewPercentageDiscount() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }, - - 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() + Currency = "currency", + DimensionalPriceConfiguration = 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, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - - PlanPhaseOrder = null, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 AdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void NewPlanUnitWithProrationValidationWorks() { - Adjustment value = new Models::NewPercentageDiscount() + Price value = new Models::NewPlanUnitWithProrationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void NewPlanGroupedAllocationValidationWorks() { - Adjustment value = new Models::NewUsageDiscount() + Price value = new Models::NewPlanGroupedAllocationPrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanBulkWithProrationValidationWorks() { - Adjustment value = new Models::NewAmountDiscount() + Price value = new Models::NewPlanBulkWithProrationPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedWithProratedMinimumValidationWorks() { - Adjustment value = new Models::NewMinimum() + Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedWithMeteredMinimumValidationWorks() { - Adjustment value = new Models::NewMaximum() + Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void GroupedWithMinMaxThresholdsValidationWorks() { - Adjustment value = new Models::NewPercentageDiscount() + Price value = new GroupedWithMinMaxThresholds() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - Adjustment value = new Models::NewUsageDiscount() + Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanGroupedTieredPackageValidationWorks() { - Adjustment value = new Models::NewAmountDiscount() + Price value = new Models::NewPlanGroupedTieredPackagePrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanMaxGroupTieredPackageValidationWorks() { - Adjustment value = new Models::NewMinimum() + Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanScalableMatrixWithUnitPricingValidationWorks() { - Adjustment value = new Models::NewMaximum() + Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class AddPriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - var model = new AddPrice + Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - AllocationPrice = new() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", }, - 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, }, - }; - - 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; - Price expectedPrice = new Models::NewPlanUnitPrice() + value.Validate(); + } + + [Fact] + public void NewPlanCumulativeGroupedBulkValidationWorks() + { + Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1279,199 +5042,131 @@ 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); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void CumulativeGroupedAllocationValidationWorks() { - var model = new AddPrice + Price value = new CumulativeGroupedAllocation() { - AllocationPrice = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = 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", + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, ModelBase.SerializerOptions); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void DailyCreditAllowanceValidationWorks() { - var model = new AddPrice + Price value = new DailyCreditAllowance() { - AllocationPrice = new() + Cadence = DailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = 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", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, }, - }; - - 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() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "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; - Price expectedPrice = new Models::NewPlanUnitPrice() + value.Validate(); + } + + [Fact] + public void MeteredAllowanceValidationWorks() + { + Price value = new MeteredAllowance() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1500,145 +5195,153 @@ 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(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanMinimumCompositeValidationWorks() { - var model = new AddPrice + Price value = new Models::NewPlanMinimumCompositePrice() { - AllocationPrice = new() + 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() { - 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"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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.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(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void PercentValidationWorks() { - var model = new AddPrice + Price value = new Percent() { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void EventOutputValidationWorks() { - var model = new AddPrice + Price value = new EventOutput() { - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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(); + value.Validate(); } -} -public class PriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanUnitSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitPrice() { @@ -1675,14 +5378,18 @@ 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 NewPlanTieredSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPrice() { @@ -1731,14 +5438,18 @@ 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 NewPlanBulkSerializationRoundtripWorks() { Price value = new Models::NewPlanBulkPrice() { @@ -1775,14 +5486,18 @@ 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 BulkWithFiltersSerializationRoundtripWorks() { Price value = new BulkWithFilters() { @@ -1795,7 +5510,7 @@ public void BulkWithFiltersValidationWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + Cadence = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -1826,14 +5541,18 @@ 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 NewPlanPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanPackagePrice() { @@ -1870,14 +5589,18 @@ 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 NewPlanMatrixSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixPrice() { @@ -1919,14 +5642,18 @@ 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() { Price value = new Models::NewPlanThresholdTotalAmountPrice() { @@ -1971,14 +5698,18 @@ 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 NewPlanTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPackagePrice() { @@ -2023,14 +5754,18 @@ 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() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredWithMinimumPrice() { @@ -2086,14 +5821,18 @@ 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 NewPlanGroupedTieredSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedTieredPrice() { @@ -2138,14 +5877,18 @@ 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanTieredPackageWithMinimumPrice() { @@ -2201,14 +5944,18 @@ 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanPackageWithAllocationPrice() { @@ -2250,14 +5997,18 @@ 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 NewPlanUnitWithPercentSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitWithPercentPrice() { @@ -2294,14 +6045,18 @@ 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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixWithAllocationPrice() { @@ -2344,14 +6099,18 @@ 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 TieredWithProrationSerializationRoundtripWorks() { Price value = new TieredWithProration() { @@ -2389,14 +6148,18 @@ 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 NewPlanUnitWithProrationSerializationRoundtripWorks() { Price value = new Models::NewPlanUnitWithProrationPrice() { @@ -2433,14 +6196,18 @@ 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 NewPlanGroupedAllocationSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedAllocationPrice() { @@ -2482,14 +6249,18 @@ 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 NewPlanBulkWithProrationSerializationRoundtripWorks() { Price value = new Models::NewPlanBulkWithProrationPrice() { @@ -2531,14 +6302,18 @@ 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() { @@ -2581,14 +6356,18 @@ 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { @@ -2640,14 +6419,18 @@ 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Price value = new GroupedWithMinMaxThresholds() { @@ -2689,14 +6472,18 @@ 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { Price value = new Models::NewPlanMatrixWithDisplayNamePrice() { @@ -2745,14 +6532,18 @@ 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanGroupedTieredPackagePrice() { @@ -2798,14 +6589,18 @@ 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { Price value = new Models::NewPlanMaxGroupTieredPackagePrice() { @@ -2851,14 +6646,18 @@ 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { @@ -2880,6 +6679,7 @@ public void NewPlanScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2911,14 +6711,18 @@ 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { @@ -2974,14 +6778,18 @@ 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); } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { Price value = new Models::NewPlanCumulativeGroupedBulkPrice() { @@ -3030,27 +6838,235 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() 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 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", + }; + 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 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() + { + 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", + }; + 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 CumulativeGroupedAllocationValidationWorks() + public void PercentSerializationRoundtripWorks() { - Price value = new CumulativeGroupedAllocation() + Price value = new Percent() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3079,20 +7095,29 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void EventOutputSerializationRoundtripWorks() { - Price value = new Minimum() + Price value = new EventOutput() { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -3122,21 +7147,35 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); } +} +public class BulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new BulkWithFilters { - 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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3166,21 +7205,102 @@ public void NewPlanMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + 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 PercentValidationWorks() + public void SerializationRoundtrip_Works() { - Price value = new Percent() + var model = new BulkWithFilters { - Cadence = PercentCadence.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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3209,24 +7329,35 @@ public void PercentValidationWorks() 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 EventOutputValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new EventOutput() + var model = new BulkWithFilters { - Cadence = EventOutputCadence.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 = BulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -3257,22 +7388,112 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + + string element = JsonSerializer.Serialize(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 NewPlanUnitSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanUnitPrice() + 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() @@ -3301,125 +7522,89 @@ 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); + model.Validate(); } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Price value = new Models::NewPlanTieredPrice() + var model = new BulkWithFilters { - 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, - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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")); } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Price value = new Models::NewPlanBulkPrice() + var model = new BulkWithFilters { - 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() + 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 = 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); + model.Validate(); } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new BulkWithFilters() + var model = new BulkWithFilters { BulkWithFiltersConfig = new() { @@ -3430,56 +7615,110 @@ public void BulkWithFiltersSerializationRoundtripWorks() new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - Cadence = Cadence.Annual, + 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() + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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() { - 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 = 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanPackagePrice() + var model = new BulkWithFilters { - Cadence = Models::NewPlanPackagePriceCadence.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::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3508,379 +7747,467 @@ 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); + 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 NewPlanMatrixSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Price value = new Models::NewPlanMatrixPrice() + var model = new Tier { - 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", + + 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Price value = new Models::NewPlanThresholdTotalAmountPrice() + var model = new Tier { - 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); + model.Validate(); } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_Works() { - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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, - }, - 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>( + 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 NewPlanGroupedTieredSerializationRoundtripWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanGroupedTieredPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() - { - GroupingKey = "x", - Tiers = + 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() { 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", + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Price value = new Models::NewPlanTieredPackageWithMinimumPrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() - { - PackageSize = 0, - Tiers = + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + ] + ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } +} +public class TieredWithProrationTest : TestBase +{ [Fact] - public void NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanPackageWithAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3909,78 +8236,91 @@ 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); - } - [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() - { - Price value = new Models::NewPlanUnitWithPercentPrice() + 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::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() + 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(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, deserialized); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.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", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4009,19 +8349,24 @@ 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); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new TieredWithProration() + var model = new TieredWithProration { Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", @@ -4057,25 +8402,101 @@ 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 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanUnitWithProrationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.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() @@ -4104,30 +8525,173 @@ 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); + 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 NewPlanGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new Models::NewPlanGroupedAllocationPrice() + var model = new TieredWithProration { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4156,367 +8720,355 @@ 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); + + 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 NewPlanBulkWithProrationSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Price value = new Models::NewPlanBulkWithProrationPrice() + 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 { - 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", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, model.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], model.Tiers[i]); + } + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + List expectedTiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ]; + + Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); + for (int i = 0; i < expectedTiers.Count; i++) + { + Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); + } + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationConfigTierTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "unit_amount"; + + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - string 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 NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new TieredWithProrationConfigTier { - 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", + 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 NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new TieredWithProrationConfigTier { - 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", + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new GroupedWithMinMaxThresholds() + var model = new TieredWithProrationConfigTier { - 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", + 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); + TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); } +} +public class TieredWithProrationConversionRateConfigTest : TestBase +{ [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void UnitValidationWorks() { - Price value = new Models::NewPlanMatrixWithDisplayNamePrice() + TieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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() + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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() + 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 NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4546,41 +9098,104 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + 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, 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = 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", + 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() @@ -4609,44 +9224,35 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Price value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", + 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() @@ -4675,36 +9281,113 @@ 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); + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() { - Price value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new GroupedWithMinMaxThresholds { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4734,27 +9417,190 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new GroupedWithMinMaxThresholds + { + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + + BillableMetricID = null, + BilledInAdvance = null, + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Price value = new CumulativeGroupedAllocation() + var model = new GroupedWithMinMaxThresholds { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -4786,223 +9632,283 @@ 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); + + 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 MinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Price value = new Minimum() + var model = new GroupedWithMinMaxThresholdsConfig { - 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", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + 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 NewPlanMinimumCompositeSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Price value = new Models::NewPlanMinimumCompositePrice() + var model = new GroupedWithMinMaxThresholdsConfig { - 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", + 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", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitValidationWorks() { - 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() + GroupedWithMinMaxThresholdsConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() + { + GroupedWithMinMaxThresholdsConversionRateConfig 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() { - 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() + 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 BulkWithFiltersTest : TestBase +public class CumulativeGroupedAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5033,22 +9939,24 @@ 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 = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5058,7 +9966,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5079,11 +9987,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( + expectedCumulativeGroupedAllocationConfig, + model.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -5098,6 +10010,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10025,16 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5154,12 +10065,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 +10082,16 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5212,29 +10122,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); - BulkWithFiltersConfig expectedBulkWithFiltersConfig = new() + ApiEnum expectedCadence = + CumulativeGroupedAllocationCadence.Annual; + CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - ApiEnum expectedCadence = Cadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -5244,7 +10156,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - ConversionRateConfig expectedConversionRateConfig = + CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5265,11 +10177,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( + expectedCumulativeGroupedAllocationConfig, + deserialized.CumulativeGroupedAllocationConfig + ); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -5287,6 +10203,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10218,16 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -5343,6 +10258,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 +10269,16 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5391,6 +10305,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10316,16 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", }; @@ -5422,18 +10336,16 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5448,6 +10360,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5474,6 +10387,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10398,16 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new BulkWithFilters + var model = new CumulativeGroupedAllocation { - BulkWithFiltersConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = Cadence.Annual, ItemID = "item_id", Name = "Annual fee", @@ -5509,197 +10422,172 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class BulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = [new() { PropertyKey = "x", PropertyValue = "x" }]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { - var model = new BulkWithFiltersConfig + var model = new CumulativeGroupedAllocation { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - - 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" }, - ], - }; + CumulativeGroupedAllocation copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class FilterTest : TestBase +public class CumulativeGroupedAllocationCadenceTest : TestBase { - [Fact] - public void FieldRoundtrip_Works() + [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) { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; - - Assert.Equal(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(json, ModelBase.SerializerOptions); + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); - Assert.Equal(model, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void FieldRoundtripThroughSerialization_Works() + [Theory] + [InlineData(CumulativeGroupedAllocationCadence.Annual)] + [InlineData(CumulativeGroupedAllocationCadence.SemiAnnual)] + [InlineData(CumulativeGroupedAllocationCadence.Monthly)] + [InlineData(CumulativeGroupedAllocationCadence.Quarterly)] + [InlineData(CumulativeGroupedAllocationCadence.OneTime)] + [InlineData(CumulativeGroupedAllocationCadence.Custom)] + public void SerializationRoundtrip_Works(CumulativeGroupedAllocationCadence rawValue) { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - Assert.NotNull(deserialized); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); - Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void InvalidEnumSerializationRoundtrip_Works() { - var model = new Filter { PropertyKey = "x", PropertyValue = "x" }; + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); - model.Validate(); + Assert.Equal(value, deserialized); } } -public class TierTest : TestBase +public class CumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -5707,184 +10595,113 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + 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); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] public void Validation_Works() { - var model = new 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 + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", UnitAmount = "unit_amount", - - TierLowerBound = null, }; - 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 Tier + var model = new CumulativeGroupedAllocationConfig { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", 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 - ); + CumulativeGroupedAllocationConfig copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class ConversionRateConfigTest : TestBase +public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + CumulativeGroupedAllocationConversionRateConfig 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, - }, - ] - ), - }; + 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() { - ConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + 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 deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -5892,43 +10709,50 @@ 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, - }, - ] - ), - }; + 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 deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class TieredWithProrationTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProration + var model = 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() @@ -5957,18 +10781,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 = + 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("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_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 +10807,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5998,14 +10828,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(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); @@ -6017,6 +10848,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10863,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProration + var model = 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() @@ -6067,12 +10904,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 +10921,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProration + var model = 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() @@ -6119,25 +10962,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 = + 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("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_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 +10995,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - TieredWithProrationConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6167,14 +11016,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(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); @@ -6189,6 +11039,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11054,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new TieredWithProration + var model = 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() @@ -6239,6 +11095,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 +11106,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new TieredWithProration + var model = 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" }] - ), }; Assert.Null(model.BillableMetricID); @@ -6281,6 +11143,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11154,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new TieredWithProration + var model = 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" }] - ), }; model.Validate(); @@ -6306,14 +11175,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new TieredWithProration + var model = 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 = null, BilledInAdvance = null, @@ -6326,6 +11200,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6352,6 +11227,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11238,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new TieredWithProration + var model = 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 = null, BilledInAdvance = null, @@ -6381,34 +11263,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 TieredWithProrationCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : 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(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 ); @@ -6418,19 +11355,19 @@ public void InvalidEnumValidationThrows_Works() } [Theory] - [InlineData(TieredWithProrationCadence.Annual)] - [InlineData(TieredWithProrationCadence.SemiAnnual)] - [InlineData(TieredWithProrationCadence.Monthly)] - [InlineData(TieredWithProrationCadence.Quarterly)] - [InlineData(TieredWithProrationCadence.OneTime)] - [InlineData(TieredWithProrationCadence.Custom)] - public void SerializationRoundtrip_Works(TieredWithProrationCadence rawValue) + [InlineData(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>( + var deserialized = JsonSerializer.Deserialize>( json, ModelBase.SerializerOptions ); @@ -6441,12 +11378,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 +11392,58 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class TieredWithProrationConfigTest : TestBase +public class DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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]); } } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6497,71 +11454,104 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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( + var deserialized = 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]); } } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfig + var model = new DailyCreditAllowanceConfig { - 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(); } -} -public class TieredWithProrationConfigTierTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new TieredWithProrationConfigTier + var model = new DailyCreditAllowanceConfig { - 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 expectedTierLowerBound = "tier_lower_bound"; + DailyCreditAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + 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); } [Fact] public void SerializationRoundtrip_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6572,56 +11562,63 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { 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 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); } [Fact] public void Validation_Works() { - var model = new TieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } } -public class TieredWithProrationConversionRateConfigTest : TestBase +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - TieredWithProrationConversionRateConfig 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() { - TieredWithProrationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6642,13 +11639,14 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig 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 ); @@ -6659,7 +11657,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6675,7 +11673,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6684,22 +11682,24 @@ public void TieredSerializationRoundtripWorks() } } -public class GroupedWithMinMaxThresholdsTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6729,23 +11729,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 = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig 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; @@ -6755,7 +11755,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6776,15 +11776,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( - 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); @@ -6798,6 +11796,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6812,17 +11811,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6852,12 +11853,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 ); @@ -6868,17 +11870,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -6908,30 +11912,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 = MeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + MeteredAllowanceConfig 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; @@ -6941,7 +11945,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - GroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6962,15 +11966,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( - 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); @@ -6987,6 +11989,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7001,17 +12004,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7041,6 +12046,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7051,17 +12057,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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", }; @@ -7087,6 +12095,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7096,17 +12106,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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", }; @@ -7116,17 +12128,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7140,6 +12154,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7166,6 +12181,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7175,17 +12192,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new GroupedWithMinMaxThresholds + var model = new MeteredAllowance { - Cadence = GroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = MeteredAllowanceCadence.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, @@ -7199,34 +12218,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 GroupedWithMinMaxThresholdsCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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(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 ); @@ -7236,21 +12311,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(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< - ApiEnum - >(json, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize>( + json, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7258,56 +12334,65 @@ 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 MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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 GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 ); @@ -7318,97 +12403,189 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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( + var deserialized = 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 GroupedWithMinMaxThresholdsConfig + var model = new MeteredAllowanceConfig { + 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 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 GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + MeteredAllowanceConversionRateConfig 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, - }, - ] - ), - }; + 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() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + 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 - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } @@ -7416,49 +12593,41 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = - new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; + 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 - ); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class CumulativeGroupedAllocationTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7487,24 +12656,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 = - CumulativeGroupedAllocationCadence.Annual; - CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + ApiEnum expectedCadence = PercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + 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() @@ -7513,7 +12674,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7534,17 +12695,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( - 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); @@ -7556,6 +12715,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7570,18 +12730,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7610,15 +12764,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); } @@ -7626,18 +12778,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7666,31 +12812,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 = - 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" - ); + 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() @@ -7699,7 +12837,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - CumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + PercentConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7720,17 +12858,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( - 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); @@ -7745,6 +12881,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7759,18 +12896,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -7799,6 +12930,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7809,18 +12941,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -7845,6 +12971,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7854,18 +12982,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -7874,18 +12996,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7898,6 +13014,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7924,6 +13041,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7933,18 +13052,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new CumulativeGroupedAllocation + var model = new Percent { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, + Cadence = PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -7957,34 +13070,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 CumulativeGroupedAllocationCadenceTest : TestBase +public class PercentCadenceTest : 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(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 ); @@ -7994,21 +13155,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(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); } @@ -8016,56 +13178,39 @@ 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 PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new PercentConfig { 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 CumulativeGroupedAllocationConfig - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }; + var model = new PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8074,142 +13219,307 @@ public void SerializationRoundtrip_Works() } [Fact] - public void FieldRoundtripThroughSerialization_Works() + 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() { - var model = new CumulativeGroupedAllocationConfig + PercentConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - 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 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); + Assert.Equal(value, deserialized); } [Fact] - public void Validation_Works() + public void TieredSerializationRoundtripWorks() { - var model = new CumulativeGroupedAllocationConfig + PercentConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + ConversionRateType = Models::ConversionRateType.Tiered, + 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class EventOutputTest : TestBase { [Fact] - public void UnitValidationWorks() + public void FieldRoundtrip_Works() { - CumulativeGroupedAllocationConversionRateConfig 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() - { - CumulativeGroupedAllocationConversionRateConfig 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() - { - CumulativeGroupedAllocationConversionRateConfig 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() { - CumulativeGroupedAllocationConversionRateConfig 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 MinimumTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8239,18 +13549,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 = MinimumCadence.Annual; - string expectedItemID = "item_id"; - MinimumConfig expectedMinimumConfig = 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() { - MinimumAmount = "minimum_amount", - Prorated = true, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8260,7 +13579,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = + EventOutputConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8281,44 +13600,54 @@ 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(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(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); + 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(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(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { - var model = new Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8348,24 +13677,187 @@ 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); + model.Validate(); + } - Assert.Equal(model, deserialized); + [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 FieldRoundtripThroughSerialization_Works() + 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 Minimum + var model = new EventOutput { - Cadence = MinimumCadence.Annual, + Cadence = EventOutputCadence.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, @@ -8395,354 +13887,436 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + 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(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() + 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 { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - double expectedConversionRate = 0; - MinimumConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + 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 { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::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 EventOutputConfig { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - 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 + string element = JsonSerializer.Serialize(model, 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.NotNull(deserialized); - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + 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 Minimum + var model = new EventOutputConfig { - 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", + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Minimum + var model = new EventOutputConfig { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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")); + EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitValidationWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - - model.Validate(); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredValidationWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } - 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, + [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.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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 TieredSerializationRoundtripWorks() { - var model = new Minimum + EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - 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, + ConversionRateType = Models::ConversionRateType.Tiered, + 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 MinimumCadenceTest : TestBase +public class RemoveAdjustmentTest : 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) + [Fact] + public void FieldRoundtrip_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); + 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 InvalidEnumValidationThrows_Works() + public void SerializationRoundtrip_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(model, deserialized); } - [Theory] - [InlineData(MinimumCadence.Annual)] - [InlineData(MinimumCadence.SemiAnnual)] - [InlineData(MinimumCadence.Monthly)] - [InlineData(MinimumCadence.Quarterly)] - [InlineData(MinimumCadence.OneTime)] - [InlineData(MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(MinimumCadence rawValue) + [Fact] + public void FieldRoundtripThroughSerialization_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); + + 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", - Assert.Equal(value, deserialized); + PlanPhaseOrder = null, + }; + + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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 RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; - Assert.Equal(value, deserialized); + RemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); } } -public class MinimumConfigTest : TestBase +public class RemovePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); } [Fact] public void SerializationRoundtrip_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + 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 ); @@ -8753,304 +14327,178 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + string expectedPriceID = "price_id"; + long expectedPlanPhaseOrder = 0; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedPriceID, deserialized.PriceID); + Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); } [Fact] public void Validation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount", Prorated = true }; + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new RemovePrice { PriceID = "price_id" }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.PlanPhaseOrder); + Assert.False(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new MinimumConfig { MinimumAmount = "minimum_amount" }; + var model = new RemovePrice { PriceID = "price_id" }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new MinimumConfig + var model = new RemovePrice { - MinimumAmount = "minimum_amount", + PriceID = "price_id", - // Null should be interpreted as omitted for these properties - Prorated = null, + PlanPhaseOrder = null, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + Assert.Null(model.PlanPhaseOrder); + Assert.True(model.RawData.ContainsKey("plan_phase_order")); } [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new MinimumConfig + var model = new RemovePrice { - MinimumAmount = "minimum_amount", + PriceID = "price_id", - // Null should be interpreted as omitted for these properties - Prorated = null, + PlanPhaseOrder = null, }; model.Validate(); } -} - -public class MinimumConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - value.Validate(); - } - - [Fact] - public void TieredValidationWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); - } [Fact] - public void UnitSerializationRoundtripWorks() + public void CopyConstructor_Works() { - MinimumConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } + var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; - [Fact] - public void TieredSerializationRoundtripWorks() - { - MinimumConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + RemovePrice copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class PercentTest : TestBase +public class ReplaceAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - 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() + 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, }; - 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() + 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, 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)); + 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 Percent + var model = new ReplaceAdjustment { - 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() + 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); } @@ -9058,157 +14506,94 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - 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() + 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 = 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() + 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.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)); + 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 Percent + var model = new ReplaceAdjustment { - 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() + Adjustment = new Models::NewPercentageDiscount() { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["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(); @@ -9217,51 +14602,61 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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 Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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(); @@ -9270,246 +14665,360 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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 Percent + var model = new ReplaceAdjustment { - Cadence = PercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), + 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, }; 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 PercentCadenceTest : TestBase +public class ReplaceAdjustmentAdjustmentTest : TestBase { - [Theory] - [InlineData(PercentCadence.Annual)] - [InlineData(PercentCadence.SemiAnnual)] - [InlineData(PercentCadence.Monthly)] - [InlineData(PercentCadence.Quarterly)] - [InlineData(PercentCadence.OneTime)] - [InlineData(PercentCadence.Custom)] - public void Validation_Works(PercentCadence rawValue) + [Fact] + public void NewPercentageDiscountValidationWorks() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + 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 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) + public void NewUsageDiscountValidationWorks() { - // force 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); + 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 InvalidEnumSerializationRoundtrip_Works() + public void NewAmountDiscountValidationWorks() { - 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); + 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(); } -} -public class PercentConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewMinimumValidationWorks() { - var model = new PercentConfig { Percent = 0 }; - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, model.Percent); + 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 SerializationRoundtrip_Works() + public void NewMaximumValidationWorks() { - var model = new PercentConfig { Percent = 0 }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + 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 FieldRoundtripThroughSerialization_Works() + public void NewPercentageDiscountSerializationRoundtripWorks() { - var model = new PercentConfig { Percent = 0 }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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.NotNull(deserialized); - - double expectedPercent = 0; - - Assert.Equal(expectedPercent, deserialized.Percent); - } - - [Fact] - public void Validation_Works() - { - var model = new PercentConfig { Percent = 0 }; - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class PercentConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewUsageDiscountSerializationRoundtripWorks() { - PercentConversionRateConfig 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() { - PercentConversionRateConfig 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() { - PercentConversionRateConfig 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 ); @@ -9518,24 +15027,30 @@ public void UnitSerializationRoundtripWorks() } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewMaximumSerializationRoundtripWorks() { - PercentConversionRateConfig 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 ); @@ -9544,22 +15059,213 @@ public void TieredSerializationRoundtripWorks() } } -public class EventOutputTest : TestBase +public class ReplacePriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutput + var model = new ReplacePrice { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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() @@ -9588,93 +15294,322 @@ 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", - }; - 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() + 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 { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = 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", + 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 expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::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 ReplacePrice { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + 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", + }, }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); - } + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new EventOutput + string expectedReplacesPriceID = "replaces_price_id"; + Models::NewAllocationPrice expectedAllocationPrice = new() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() + Amount = "10.00", + Cadence = Models::Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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() @@ -9703,33 +15638,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 EventOutput + long expectedPlanPhaseOrder = 0; + ReplacePricePrice expectedPrice = new Models::NewPlanUnitPrice() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -9758,133 +15678,139 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); - - ApiEnum expectedCadence = EventOutputCadence.Annual; - EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - Models::NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - EventOutputConversionRateConfig expectedConversionRateConfig = - new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); - - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + 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 EventOutput + var model = new ReplacePrice { - 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() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + 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", }, - Currency = "currency", - DimensionalPriceConfiguration = new() + LicenseAllocationPrice = new() { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + 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", }, - 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", }; model.Validate(); @@ -9893,62 +15819,22 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new ReplacePrice { 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.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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.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 EventOutput - { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new ReplacePrice { ReplacesPriceID = "replaces_price_id" }; model.Validate(); } @@ -9956,194 +15842,365 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [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, - Metadata = null, - ReferenceID = null, - }; - - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.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 EventOutput + var model = new ReplacePrice { - Cadence = EventOutputCadence.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, - ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, }; - model.Validate(); - } -} - -public class EventOutputCadenceTest : TestBase -{ - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void Validation_Works(EventOutputCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); + 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")); } - [Theory] - [InlineData(EventOutputCadence.Annual)] - [InlineData(EventOutputCadence.SemiAnnual)] - [InlineData(EventOutputCadence.Monthly)] - [InlineData(EventOutputCadence.Quarterly)] - [InlineData(EventOutputCadence.OneTime)] - [InlineData(EventOutputCadence.Custom)] - public void SerializationRoundtrip_Works(EventOutputCadence rawValue) + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + var model = new ReplacePrice + { + ReplacesPriceID = "replaces_price_id", - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize>( - json, - ModelBase.SerializerOptions - ); + AllocationPrice = null, + LicenseAllocationPrice = null, + PlanPhaseOrder = null, + Price = null, + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void InvalidEnumSerializationRoundtrip_Works() + public void CopyConstructor_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); + ReplacePrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::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"; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "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(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.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 ); @@ -10154,194 +16211,543 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + ApiEnum expectedCadence = + ReplacePriceLicenseAllocationPriceCadence.Annual; + string expectedItemID = "item_id"; + 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() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + ReplacePriceLicenseAllocationPriceConversionRateConfig expectedConversionRateConfig = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string expectedCurrency = "currency"; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "x"; + Models::NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }; + string expectedLicenseTypeID = "license_type_id"; + Dictionary expectedMetadata = new() { { "foo", "string" } }; + string expectedReferenceID = "reference_id"; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedItemID, deserialized.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 Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - 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 }, }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_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")); - } + 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 }, - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new EventOutputConfig { UnitRatingKey = "x" }; + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - UnitRatingKey = "x", + 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 }, - DefaultUnitRate = null, - GroupingKey = 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.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { - var model = new EventOutputConfig + var model = new ReplacePriceLicenseAllocationPrice { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + 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(); + ReplacePriceLicenseAllocationPrice copied = new(model); + + Assert.Equal(model, copied); } } -public class EventOutputConversionRateConfigTest : TestBase +public class ReplacePriceLicenseAllocationPriceCadenceTest : TestBase { - [Fact] - public void UnitValidationWorks() + [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) { - EventOutputConversionRateConfig value = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; value.Validate(); } [Fact] - public void TieredValidationWorks() + public void InvalidEnumValidationThrows_Works() { - EventOutputConversionRateConfig value = new Models::SharedTieredConversionRateConfig() - { - ConversionRateType = Models::ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), - }; - value.Validate(); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void UnitSerializationRoundtripWorks() + [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) { - 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 - ); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } [Fact] - public void TieredSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - 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 - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid 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 ReplacePriceLicenseAllocationPriceLicenseAllocationTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(expectedAmount, model.Amount); + Assert.Equal(expectedCurrency, model.Currency); + Assert.Equal(expectedWriteOffOverage, model.WriteOffOverage); } [Fact] public void SerializationRoundtrip_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); Assert.Equal(model, deserialized); } @@ -10349,26 +16755,39 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.NotNull(deserialized); - string expectedAdjustmentID = "adjustment_id"; - long expectedPlanPhaseOrder = 0; + string expectedAmount = "amount"; + string expectedCurrency = "currency"; + bool expectedWriteOffOverage = true; - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + Assert.Equal(expectedAmount, deserialized.Amount); + Assert.Equal(expectedCurrency, deserialized.Currency); + Assert.Equal(expectedWriteOffOverage, deserialized.WriteOffOverage); } [Fact] public void Validation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; model.Validate(); } @@ -10376,16 +16795,24 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.False(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new RemoveAdjustment { AdjustmentID = "adjustment_id" }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + }; model.Validate(); } @@ -10393,855 +16820,1179 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new RemoveAdjustment + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - AdjustmentID = "adjustment_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Null(model.WriteOffOverage); + Assert.True(model.RawData.ContainsKey("write_off_overage")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new RemoveAdjustment + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation { - AdjustmentID = "adjustment_id", + Amount = "amount", + Currency = "currency", - PlanPhaseOrder = null, + WriteOffOverage = null, }; model.Validate(); } -} -public class RemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var model = new ReplacePriceLicenseAllocationPriceLicenseAllocation + { + Amount = "amount", + Currency = "currency", + WriteOffOverage = true, + }; - string expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + ReplacePriceLicenseAllocationPriceLicenseAllocation copied = new(model); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); + Assert.Equal(model, copied); } +} - [Fact] - public void SerializationRoundtrip_Works() +public class ReplacePriceLicenseAllocationPriceModelTypeTest : TestBase +{ + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void Validation_Works(ReplacePriceLicenseAllocationPriceModelType rawValue) { - 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); + // 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 RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + 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 expectedPriceID = "price_id"; - long expectedPlanPhaseOrder = 0; + [Theory] + [InlineData(ReplacePriceLicenseAllocationPriceModelType.Unit)] + public void SerializationRoundtrip_Works(ReplacePriceLicenseAllocationPriceModelType rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; - Assert.Equal(expectedPriceID, deserialized.PriceID); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); + 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 RemovePrice { PriceID = "price_id", PlanPhaseOrder = 0 }; + var value = 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 ReplacePriceLicenseAllocationPriceConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void UnitValidationWorks() { - var model = new RemovePrice { PriceID = "price_id" }; + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + [Fact] + public void TieredValidationWorks() + { + ReplacePriceLicenseAllocationPriceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void UnitSerializationRoundtripWorks() { - var model = new RemovePrice { PriceID = "price_id" }; + 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 + ); - model.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void TieredSerializationRoundtripWorks() { - var model = new RemovePrice - { - PriceID = "price_id", - - PlanPhaseOrder = null, - }; + 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 + ); - Assert.Null(model.PlanPhaseOrder); - Assert.True(model.RawData.ContainsKey("plan_phase_order")); + Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanUnitValidationWorks() { - var model = new RemovePrice + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - PriceID = "price_id", - - PlanPhaseOrder = null, + 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(); + value.Validate(); } -} -public class ReplaceAdjustmentTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanTieredValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorated = true, + }, + BillableMetricID = "billable_metric_id", + 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 = 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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 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 NewPlanBulkValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanBulkPrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["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, }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new 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 BulkWithFiltersValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - Adjustment = new Models::NewPercentageDiscount() + BulkWithFiltersConfig = new() { - 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() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], - 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"], + 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", - 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 NewPlanPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + 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() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - PlanPhaseOrder = 0, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanMatrixValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = 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, + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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", }; - - Assert.Null(model.PlanPhaseOrder); - Assert.False(model.RawData.ContainsKey("plan_phase_order")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void NewPlanThresholdTotalAmountValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + Name = "Annual fee", + ThresholdTotalAmountConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + ConsumptionTable = [ - new() - { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + Prorate = true, }, - ReplacesAdjustmentID = "replaces_adjustment_id", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 NewPlanTieredPackageValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, + Name = "Annual fee", + TieredPackageConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + 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 = 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 NewPlanTieredWithMinimumValidationWorks() { - var model = new ReplaceAdjustment + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Adjustment = new Models::NewPercentageDiscount() + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + Name = "Annual fee", + TieredWithMinimumConfig = new() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = + Tiers = [ new() { - Field = Models::NewPercentageDiscountFilterField.PriceID, - Operator = Models::NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }, ], - IsInvoiceLevel = true, - PriceType = Models::NewPercentageDiscountPriceType.Usage, + 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"), }, - 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, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = 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() + public void NewPlanGroupedTieredValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanTieredPackageWithMinimumValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanPackageWithAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanUnitWithPercentValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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() + public void NewPlanMatrixWithAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewPercentageDiscount() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - AdjustmentType = Models::NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = Models::NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + value.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewUsageDiscount() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - AdjustmentType = Models::NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = Models::NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanUnitWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewAmountDiscount() + ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() { - AdjustmentType = Models::NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = Models::AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void NewPlanGroupedAllocationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMinimum() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - AdjustmentType = Models::NewMinimumAdjustmentType.Minimum, + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = Models::NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewPlanBulkWithProrationValidationWorks() { - ReplaceAdjustmentAdjustment value = new Models::NewMaximum() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - AdjustmentType = Models::NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = Models::NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class ReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewPlanGroupedWithProratedMinimumValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = 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", + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ItemID = "item_id", + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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, }, - }; - - 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() + value.Validate(); + } + + [Fact] + public void NewPlanGroupedWithMeteredMinimumValidationWorks() + { + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11270,206 +18021,139 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = 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", + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + 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, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewPlanMatrixWithDisplayNameValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + Dimension = "dimension", + UnitAmounts = [ new() { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + 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, }, - }; - - 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() + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "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() + value.Validate(); + } + + [Fact] + public void NewPlanGroupedTieredPackageValidationWorks() + { + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanUnitPriceCadence.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::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11498,159 +18182,158 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - - Assert.Equal(expectedReplacesPriceID, deserialized.ReplacesPriceID); - Assert.Equal(expectedAllocationPrice, deserialized.AllocationPrice); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedPrice, deserialized.Price); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewPlanMaxGroupTieredPackageValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - Amount = "10.00", - Cadence = Models::Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = Models::CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() - { - Field = Models::NewAllocationPriceFilterField.ItemID, - Operator = Models::NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", }, - PlanPhaseOrder = 0, - Price = new Models::NewPlanUnitPrice() + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + 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", }; - - 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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewPlanScalableMatrixWithUnitPricingValidationWorks() { - var model = new ReplacePrice + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - PlanPhaseOrder = null, - Price = null, + 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", }; - - model.Validate(); + value.Validate(); } -} -public class ReplacePricePriceTest : TestBase -{ [Fact] - public void NewPlanUnitValidationWorks() + public void NewPlanScalableMatrixWithTieredPricingValidationWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -11679,6 +18362,7 @@ public void NewPlanUnitValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11686,27 +18370,27 @@ public void NewPlanUnitValidationWorks() } [Fact] - public void NewPlanTieredValidationWorks() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, - Name = "Annual fee", - TieredConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Tiers = + DimensionValues = [ new() { - FirstUnit = 0, + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount", - LastUnit = 0, }, ], - Prorated = true, + Group = "group", }, + ItemID = "item_id", + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11735,6 +18419,7 @@ public void NewPlanTieredValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11742,14 +18427,19 @@ public void NewPlanTieredValidationWorks() } [Fact] - public void NewPlanBulkValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11779,6 +18469,7 @@ public void NewPlanBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11786,20 +18477,19 @@ public void NewPlanBulkValidationWorks() } [Fact] - public void BulkWithFiltersValidationWorks() + public void DailyCreditAllowanceValidationWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - BulkWithFiltersConfig = new() + Cadence = ReplacePricePriceDailyCreditAllowanceCadence.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 = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -11830,6 +18520,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11837,15 +18528,22 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewPlanPackageValidationWorks() + public void MeteredAllowanceValidationWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanPackagePriceModelType.Package, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11874,6 +18572,7 @@ public void NewPlanPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11881,19 +18580,14 @@ public void NewPlanPackageValidationWorks() } [Fact] - public void NewPlanMatrixValidationWorks() + public void NewPlanMinimumCompositeValidationWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() - { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], - }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -11923,6 +18617,7 @@ public void NewPlanMatrixValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11930,23 +18625,14 @@ public void NewPlanMatrixValidationWorks() } [Fact] - public void NewPlanThresholdTotalAmountValidationWorks() + public void PercentValidationWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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, - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11975,6 +18661,7 @@ public void NewPlanThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11982,23 +18669,19 @@ public void NewPlanThresholdTotalAmountValidationWorks() } [Fact] - public void NewPlanTieredPackageValidationWorks() + public void EventOutputValidationWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12027,6 +18710,7 @@ public void NewPlanTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12034,34 +18718,15 @@ public void NewPlanTieredPackageValidationWorks() } [Fact] - public void NewPlanTieredWithMinimumValidationWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanUnitPrice() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + ModelType = Models::NewPlanUnitPriceModelType.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, - }, + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12090,30 +18755,41 @@ 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 NewPlanTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + ReplacePricePrice value = new Models::NewPlanTieredPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - GroupingKey = "x", Tiers = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12142,41 +18818,29 @@ 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 NewPlanBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + ReplacePricePrice value = new Models::NewPlanBulkPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Models::NewPlanBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Models::NewPlanBulkPriceModelType.Bulk, 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 +18869,36 @@ 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 BulkWithFiltersSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -12254,22 +18927,29 @@ 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 NewPlanPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + ReplacePricePrice value = new Models::NewPlanPackagePrice() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.Annual, + Cadence = Models::NewPlanPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, + ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12298,27 +18978,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 NewPlanMatrixSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + ReplacePricePrice value = new Models::NewPlanMatrixPrice() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = Models::NewPlanMatrixPriceCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MatrixConfig = new() { - Allocation = "allocation", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12348,23 +19034,37 @@ 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 NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() { - Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", + ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12393,22 +19093,37 @@ 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 NewPlanTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, + ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12437,27 +19152,48 @@ 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 NewPlanTieredWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, + 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() @@ -12486,26 +19222,36 @@ 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 NewPlanGroupedTieredSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() { - BulkWithProrationConfig = new( + Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() + { + GroupingKey = "x", + Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, + ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12535,28 +19281,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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() { - Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + 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() @@ -12585,37 +19351,34 @@ 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - 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::NewPlanPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - ModelType = - Models::NewPlanGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + 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() @@ -12644,27 +19407,29 @@ 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 NewPlanUnitWithPercentSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -12693,33 +19458,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 NewPlanMatrixWithAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + MatrixWithAllocationConfig = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -12749,31 +19515,30 @@ 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 TieredWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePriceTieredWithProration() { - 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" }, - ], - }, + Cadence = ReplacePricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12802,31 +19567,29 @@ 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 NewPlanUnitWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() { - Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanUnitWithProrationPriceCadence.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, + ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12855,38 +19618,34 @@ 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 NewPlanGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = 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", + 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() @@ -12915,41 +19674,34 @@ 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 NewPlanBulkWithProrationSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() { - Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.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::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, 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() @@ -12978,33 +19730,34 @@ 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); } [Fact] - public void NewPlanCumulativeGroupedBulkValidationWorks() + public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, ItemID = "item_id", - ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13034,26 +19787,43 @@ public void NewPlanCumulativeGroupedBulkValidationWorks() 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 CumulativeGroupedAllocationValidationWorks() + public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() + ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Models::NewPlanGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + 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, @@ -13083,20 +19853,33 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceMinimum() + ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = ReplacePricePriceMinimumCadence.Annual, + Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.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, @@ -13126,21 +19909,40 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanMinimumCompositeValidationWorks() + public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() + ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, + 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, @@ -13170,21 +19972,38 @@ public void NewPlanMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() + ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = ReplacePricePricePercentCadence.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::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13213,25 +20032,37 @@ public void PercentValidationWorks() 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 EventOutputValidationWorks() + public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceEventOutput() + ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = ReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13261,22 +20092,46 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - value.Validate(); + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanUnitPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -13305,6 +20160,7 @@ public void NewPlanUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13318,26 +20174,33 @@ public void NewPlanUnitSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredSerializationRoundtripWorks() + public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPrice() + ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanTieredPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPriceModelType.Tiered, + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - TieredConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - Prorated = true, + 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, @@ -13367,6 +20230,7 @@ public void NewPlanTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13380,14 +20244,26 @@ public void NewPlanTieredSerializationRoundtripWorks() } [Fact] - public void NewPlanBulkSerializationRoundtripWorks() + public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanBulkPrice() + ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.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::NewPlanBulkPriceModelType.Bulk, + ModelType = Models::NewPlanCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13417,6 +20293,7 @@ public void NewPlanBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13430,20 +20307,18 @@ public void NewPlanBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { - ReplacePricePrice value = new ReplacePricePriceBulkWithFilters() + ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() { - BulkWithFiltersConfig = new() + Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -13474,6 +20349,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13487,15 +20363,21 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewPlanPackageSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanPackagePrice() + ReplacePricePrice value = new ReplacePricePriceDailyCreditAllowance() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + 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", - ModelType = Models::NewPlanPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13524,6 +20406,7 @@ public void NewPlanPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13537,19 +20420,21 @@ public void NewPlanPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanMatrixPrice() + ReplacePricePrice value = new ReplacePricePriceMeteredAllowance() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MeteredAllowanceConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13579,6 +20464,7 @@ public void NewPlanMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13592,23 +20478,15 @@ public void NewPlanMatrixSerializationRoundtripWorks() } [Fact] - public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() + public void NewPlanMinimumCompositeSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + ReplacePricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, 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() @@ -13637,6 +20515,7 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13650,23 +20529,14 @@ public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredPackageSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredPackagePrice() + ReplacePricePrice value = new ReplacePricePricePercent() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = ReplacePricePricePercentCadence.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" }, - ], - }, + Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13695,6 +20565,7 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13708,34 +20579,19 @@ public void NewPlanTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanTieredWithMinimumSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { - ReplacePricePrice value = new Models::NewPlanTieredWithMinimumPrice() + ReplacePricePrice value = new ReplacePricePriceEventOutput() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = ReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13764,6 +20620,7 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13775,24 +20632,26 @@ public void NewPlanTieredWithMinimumSerializationRoundtripWorks() Assert.Equal(value, deserialized); } +} +public class ReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewPlanGroupedTieredSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", + 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" }, ], }, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13822,47 +20681,103 @@ 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); + 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 NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + BulkWithFiltersConfig = new() { - PackageSize = 0, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, + 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() @@ -13891,33 +20806,37 @@ 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, + + 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 NewPlanPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new Models::NewPlanPackageWithAllocationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -13946,28 +20865,113 @@ 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( + + 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); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewPlanUnitWithPercentSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithPercentPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.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", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13996,135 +21000,203 @@ 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); + model.Validate(); } [Fact] - public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], 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" }, + ], }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Cadence = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new ReplacePricePriceTieredWithProration() + var model = new ReplacePricePriceBulkWithFilters { - 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() + BulkWithFiltersConfig = new() { - ConversionRateType = Models::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 = ReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new ReplacePricePriceBulkWithFilters + { + 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 NewPlanUnitWithProrationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanUnitWithProrationPrice() + var model = new ReplacePricePriceBulkWithFilters { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.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", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14153,958 +21225,539 @@ 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); + ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ [Fact] - public void NewPlanGroupedAllocationSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedAllocationPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig { - 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, - }, - 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" }, + ], + }; + + 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", }; - 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 CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanBulkWithProrationPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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", + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - ReplacePricePrice value = new ReplacePricePriceGroupedWithMinMaxThresholds() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + 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 NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void Validation_Works() { - ReplacePricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - ReplacePricePrice value = new Models::NewPlanGroupedTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + UnitAmount = "unit_amount", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - ReplacePricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - ReplacePricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void CopyConstructor_Works() { - ReplacePricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() + var model = new ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void InvalidEnumValidationThrows_Works() { - ReplacePricePrice value = new ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - Assert.Equal(value, deserialized); + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void MinimumSerializationRoundtripWorks() + [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) { - ReplacePricePrice value = new ReplacePricePriceMinimum() - { - Cadence = ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } [Fact] - public void NewPlanMinimumCompositeSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_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() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - 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 PercentSerializationRoundtripWorks() + public void UnitValidationWorks() { - ReplacePricePrice value = new ReplacePricePricePercent() - { - Cadence = ReplacePricePricePercentCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - PercentConfig = new(0), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + 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 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() + 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 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 +21786,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 +21806,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 +21827,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 +21847,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +21857,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 +21898,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 +21915,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 +21951,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 +21978,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 +21999,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 +22022,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22037,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 +22073,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 +22084,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 +22116,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22127,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 +22143,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 +22163,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -15576,6 +22190,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22199,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 +22384,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 +22539,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16037,7 +22560,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16045,7 +22568,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16056,7 +22579,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceBulkWithFiltersConversionRateConfig value = + ReplacePricePriceTieredWithProrationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16073,7 +22596,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16082,19 +22605,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 +22650,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 +22678,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 +22699,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 +22722,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +22737,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 +22777,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 +22794,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 +22834,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 +22869,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 +22890,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 +22916,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22931,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 +22971,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 +22982,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 +23018,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23029,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 +23049,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 +23073,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16516,6 +23100,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23111,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 +23135,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 +23217,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 +23225,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 +23250,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 +23312,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 +23392,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16807,7 +23413,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16815,7 +23421,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16826,7 +23432,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceTieredWithProrationConversionRateConfig value = + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -16843,7 +23449,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -16852,20 +23458,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 +23503,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 +23531,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 +23552,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 +23575,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +23590,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 +23630,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 +23647,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 +23687,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 +23722,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 +23743,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 +23769,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +23784,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 +23824,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 +23835,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 +23871,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23882,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 +23902,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 +23926,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17336,6 +23953,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23964,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 +23988,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 +24070,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 +24078,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 +24103,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 +24166,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 +24245,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17574,7 +24266,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17582,7 +24274,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17593,7 +24285,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -17610,7 +24302,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17619,20 +24311,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 +24357,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 +24384,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 +24405,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 +24425,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +24440,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 +24481,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 +24498,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 +24539,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 +24573,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 +24594,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 +24617,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +24632,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 +24673,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 +24684,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 +24721,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24732,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 +24753,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 +24778,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18103,6 +24805,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24816,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 +24924,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 +24932,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 +24955,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 +25148,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 +25219,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18341,7 +25240,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18349,7 +25248,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18360,7 +25259,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -18377,7 +25276,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18386,16 +25285,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 +25332,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 +25360,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 +25381,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 +25401,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25416,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 +25458,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 +25475,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 +25517,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 +25552,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 +25573,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 +25596,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25611,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 +25653,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 +25664,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 +25702,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25713,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 +25735,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 +25761,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18812,6 +25788,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25799,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 +25825,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 +25939,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 +26007,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 +26059,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 +26090,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 +26162,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19067,17 +26183,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 +26202,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - ReplacePricePriceMinimumConversionRateConfig value = + ReplacePricePriceMeteredAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -19101,10 +26218,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 +26267,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 +26307,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 +26327,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26376,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 +26427,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 +26474,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 +26497,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26546,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 +26587,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26630,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19528,6 +26657,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26686,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 +26856,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 +26993,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 +27038,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 +27058,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +27112,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 +27168,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 +27220,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 +27243,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +27297,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 +27343,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27396,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20223,6 +27423,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27457,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 +27710,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..3d62e169b 100644 --- a/src/Orb.Tests/Models/CustomerTaxIDTest.cs +++ b/src/Orb.Tests/Models/CustomerTaxIDTest.cs @@ -83,6 +83,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerTaxID + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }; + + CustomerTaxID copied = new(model); + + Assert.Equal(model, copied); + } } public class CountryTest : TestBase @@ -449,6 +464,7 @@ public class CustomerTaxIDTypeTest : TestBase [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] [InlineData(CustomerTaxIDType.RoTin)] [InlineData(CustomerTaxIDType.RsPib)] [InlineData(CustomerTaxIDType.RuInn)] @@ -579,6 +595,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerTaxIDType.OmVat)] [InlineData(CustomerTaxIDType.PeRuc)] [InlineData(CustomerTaxIDType.PhTin)] + [InlineData(CustomerTaxIDType.PlNip)] [InlineData(CustomerTaxIDType.RoTin)] [InlineData(CustomerTaxIDType.RsPib)] [InlineData(CustomerTaxIDType.RuInn)] diff --git a/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs b/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs index e82731e88..64734d24f 100644 --- a/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs +++ b/src/Orb.Tests/Models/Customers/AccountingProviderConfigTest.cs @@ -74,4 +74,18 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingProviderConfig + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }; + + AccountingProviderConfig copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/AddressInputTest.cs b/src/Orb.Tests/Models/Customers/AddressInputTest.cs index bc5280aa1..8b51c33e7 100644 --- a/src/Orb.Tests/Models/Customers/AddressInputTest.cs +++ b/src/Orb.Tests/Models/Customers/AddressInputTest.cs @@ -176,4 +176,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AddressInput + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }; + + AddressInput copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs b/src/Orb.Tests/Models/Customers/BalanceTransactions/BalanceTransactionCreateParamsTest.cs index b469a1d42..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..3ec87c7f8 100644 --- a/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerCreateParamsTest.cs @@ -57,6 +57,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -131,6 +132,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -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 = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["dev@stainless.com"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = ProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerCreateParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Models::Country.Ad, + Type = Models::CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + }; + + CustomerCreateParams copied = new(parameters); + + Assert.Equal(parameters, copied); } } @@ -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..8e50bc9b3 100644 --- a/src/Orb.Tests/Models/Customers/CustomerTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerTest.cs @@ -82,6 +82,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -156,6 +157,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -271,6 +273,7 @@ public void SerializationRoundtrip_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -356,6 +359,7 @@ public void FieldRoundtripThroughSerialization_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -437,6 +441,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -552,6 +557,7 @@ public void Validation_Works() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -809,6 +815,91 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Customer + { + ID = "id", + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + Balance = "balance", + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + Currency = "currency", + Email = "email", + EmailDelivery = true, + ExemptFromAutomatedTax = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentProvider = CustomerPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + PortalUrl = "portal_url", + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + Timezone = "timezone", + AccountingSyncConfiguration = new() + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }, + AutomaticTaxEnabled = true, + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + ReportingConfiguration = new(true), + }; + + Customer copied = new(model); + + Assert.Equal(model, copied); + } } public class HierarchyTest : TestBase @@ -900,6 +991,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Hierarchy + { + Children = [new() { ID = "id", ExternalCustomerID = "external_customer_id" }], + Parent = new() { ID = "id", ExternalCustomerID = "external_customer_id" }, + }; + + Hierarchy copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentProviderTest : TestBase @@ -910,6 +1015,7 @@ public class CustomerPaymentProviderTest : TestBase [InlineData(CustomerPaymentProvider.StripeCharge)] [InlineData(CustomerPaymentProvider.StripeInvoice)] [InlineData(CustomerPaymentProvider.Netsuite)] + [InlineData(CustomerPaymentProvider.NetsuiteAmpersand)] public void Validation_Works(CustomerPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -935,6 +1041,7 @@ public void InvalidEnumValidationThrows_Works() [InlineData(CustomerPaymentProvider.StripeCharge)] [InlineData(CustomerPaymentProvider.StripeInvoice)] [InlineData(CustomerPaymentProvider.Netsuite)] + [InlineData(CustomerPaymentProvider.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(CustomerPaymentProvider rawValue) { // force implicit conversion because Theory can't do that for us @@ -1086,6 +1193,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingSyncConfiguration + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }, + ], + Excluded = true, + }; + + AccountingSyncConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class AccountingProviderTest : TestBase @@ -1160,6 +1288,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new AccountingProvider + { + ExternalProviderID = "external_provider_id", + ProviderType = AccountingProviderProviderType.Quickbooks, + }; + + AccountingProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class AccountingProviderProviderTypeTest : TestBase @@ -1167,6 +1309,7 @@ public class AccountingProviderProviderTypeTest : TestBase [Theory] [InlineData(AccountingProviderProviderType.Quickbooks)] [InlineData(AccountingProviderProviderType.Netsuite)] + [InlineData(AccountingProviderProviderType.NetsuiteAmpersand)] public void Validation_Works(AccountingProviderProviderType rawValue) { // force implicit conversion because Theory can't do that for us @@ -1189,6 +1332,7 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData(AccountingProviderProviderType.Quickbooks)] [InlineData(AccountingProviderProviderType.Netsuite)] + [InlineData(AccountingProviderProviderType.NetsuiteAmpersand)] public void SerializationRoundtrip_Works(AccountingProviderProviderType rawValue) { // force implicit conversion because Theory can't do that for us @@ -1230,6 +1374,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1240,6 +1385,7 @@ public void FieldRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1262,6 +1408,7 @@ public void SerializationRoundtrip_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1286,6 +1433,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1303,6 +1451,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ]; @@ -1325,6 +1474,7 @@ public void Validation_Works() new() { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -1374,6 +1524,27 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfiguration + { + PaymentProviders = + [ + new() + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }; + + CustomerPaymentConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderTest : TestBase @@ -1384,6 +1555,7 @@ public void FieldRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1391,9 +1563,11 @@ public void FieldRoundtrip_Works() string, CustomerPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, model.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, model.DefaultSharedPaymentToken); Assert.NotNull(model.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -1414,6 +1588,7 @@ public void SerializationRoundtrip_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1432,6 +1607,7 @@ public void FieldRoundtripThroughSerialization_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1446,9 +1622,11 @@ public void FieldRoundtripThroughSerialization_Works() string, CustomerPaymentConfigurationPaymentProviderProviderType > expectedProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe; + string expectedDefaultSharedPaymentToken = "default_shared_payment_token"; List expectedExcludedPaymentMethodTypes = ["string"]; Assert.Equal(expectedProviderType, deserialized.ProviderType); + Assert.Equal(expectedDefaultSharedPaymentToken, deserialized.DefaultSharedPaymentToken); Assert.NotNull(deserialized.ExcludedPaymentMethodTypes); Assert.Equal( expectedExcludedPaymentMethodTypes.Count, @@ -1469,6 +1647,7 @@ public void Validation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }; @@ -1481,6 +1660,7 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; Assert.Null(model.ExcludedPaymentMethodTypes); @@ -1493,6 +1673,7 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", }; model.Validate(); @@ -1504,6 +1685,7 @@ public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -1519,6 +1701,7 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() var model = new CustomerPaymentConfigurationPaymentProvider { ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", // Null should be interpreted as omitted for these properties ExcludedPaymentMethodTypes = null, @@ -1526,6 +1709,75 @@ public void OptionalNonNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.False(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + Assert.Null(model.DefaultSharedPaymentToken); + Assert.True(model.RawData.ContainsKey("default_shared_payment_token")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + ExcludedPaymentMethodTypes = ["string"], + + DefaultSharedPaymentToken = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CustomerPaymentConfigurationPaymentProvider + { + ProviderType = CustomerPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }; + + CustomerPaymentConfigurationPaymentProvider copied = new(model); + + Assert.Equal(model, copied); + } } public class CustomerPaymentConfigurationPaymentProviderProviderTypeTest : TestBase @@ -1632,4 +1884,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ReportingConfiguration { Exempt = true }; + + ReportingConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs index f30346cab..fd9b5332c 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateByExternalIDParamsTest.cs @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -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 = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + Email = "dev@stainless.com", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerUpdateByExternalIDParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + }; + + CustomerUpdateByExternalIDParams copied = new(parameters); + + Assert.Equal(parameters, copied); + } } public class CustomerUpdateByExternalIDParamsPaymentConfigurationTest : TestBase @@ -342,6 +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..c01c54d4e 100644 --- a/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs +++ b/src/Orb.Tests/Models/Customers/CustomerUpdateParamsTest.cs @@ -59,6 +59,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -134,6 +135,7 @@ public void FieldRoundtrip_Works() { ProviderType = CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", ExcludedPaymentMethodTypes = ["string"], }, ], @@ -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 = "provider_type", + }, + ], + Excluded = true, + }, + AdditionalEmails = ["string"], + AutoCollection = true, + AutoIssuance = true, + BillingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + Currency = "currency", + Email = "dev@stainless.com", + EmailDelivery = true, + ExternalCustomerID = "external_customer_id", + Hierarchy = new() + { + ChildCustomerIds = ["string"], + ParentCustomerID = "parent_customer_id", + }, + Metadata = new Dictionary() { { "foo", "string" } }, + Name = "name", + PaymentConfiguration = new() + { + PaymentProviders = + [ + new() + { + ProviderType = + CustomerUpdateParamsPaymentConfigurationPaymentProviderProviderType.Stripe, + DefaultSharedPaymentToken = "default_shared_payment_token", + ExcludedPaymentMethodTypes = ["string"], + }, + ], + }, + PaymentProvider = CustomerUpdateParamsPaymentProvider.Quickbooks, + PaymentProviderID = "payment_provider_id", + ReportingConfiguration = new(true), + ShippingAddress = new() + { + City = "city", + Country = "country", + Line1 = "line1", + Line2 = "line2", + PostalCode = "postal_code", + State = "state", + }, + TaxConfiguration = new NewAvalaraTaxConfiguration() + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }, + TaxID = new() + { + Country = Country.Ad, + Type = CustomerTaxIDType.AdNrt, + Value = "value", + }, + }; + + CustomerUpdateParams copied = new(parameters); + + Assert.Equal(parameters, copied); } } @@ -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..a965d634d 100644 --- a/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewAccountingSyncConfigurationTest.cs @@ -165,4 +165,25 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAccountingSyncConfiguration + { + AccountingProviders = + [ + new() + { + ExternalProviderID = "external_provider_id", + ProviderType = "provider_type", + }, + ], + Excluded = true, + }; + + NewAccountingSyncConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs index 6a7958ef2..b541dd986 100644 --- a/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewAvalaraTaxConfigurationTest.cs @@ -151,6 +151,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewAvalaraTaxConfiguration + { + TaxExempt = true, + TaxProvider = TaxProvider.Avalara, + AutomaticTaxEnabled = true, + TaxExemptionCode = "tax_exemption_code", + }; + + NewAvalaraTaxConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class TaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs index 7e2685ae5..831882841 100644 --- a/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewReportingConfigurationTest.cs @@ -54,4 +54,14 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewReportingConfiguration { Exempt = true }; + + NewReportingConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs index 2036ae1af..698f44929 100644 --- a/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewSphereConfigurationTest.cs @@ -139,6 +139,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewSphereConfiguration + { + TaxExempt = true, + TaxProvider = NewSphereConfigurationTaxProvider.Sphere, + AutomaticTaxEnabled = true, + }; + + NewSphereConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class NewSphereConfigurationTaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs b/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs index 944681017..7bf14cfc2 100644 --- a/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs +++ b/src/Orb.Tests/Models/Customers/NewTaxJarConfigurationTest.cs @@ -139,6 +139,21 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new NewTaxJarConfiguration + { + TaxExempt = true, + TaxProvider = NewTaxJarConfigurationTaxProvider.Taxjar, + AutomaticTaxEnabled = true, + }; + + NewTaxJarConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } public class NewTaxJarConfigurationTaxProviderTest : TestBase diff --git a/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs b/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs index 1d1a6510e..f1596296f 100644 --- a/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs +++ b/src/Orb.Tests/Models/DimensionalPriceConfigurationTest.cs @@ -83,4 +83,18 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new DimensionalPriceConfiguration + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }; + + DimensionalPriceConfiguration copied = new(model); + + Assert.Equal(model, copied); + } } diff --git a/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs b/src/Orb.Tests/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParamsTest.cs index 32314559e..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..b7c4926f2 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,16 @@ public void NewPlanMinimumCompositeValidationWorks() } [Fact] - public void PercentValidationWorks() + public void TieredWithProrationValidationWorks() { - PricePrice value = new Percent() + PricePrice value = new TieredWithProration() { - Cadence = PercentCadence.Annual, + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2864,6 +4034,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2871,19 +4042,15 @@ public void PercentValidationWorks() } [Fact] - public void EventOutputValidationWorks() + public void NewPlanUnitWithProrationValidationWorks() { - PricePrice value = new EventOutput() + PricePrice value = new Models::NewPlanUnitWithProrationPrice() { - Cadence = EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -2912,6 +4079,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2919,15 +4087,20 @@ public void EventOutputValidationWorks() } [Fact] - public void NewPlanUnitSerializationRoundtripWorks() + public void NewPlanGroupedAllocationValidationWorks() { - PricePrice value = new Models::NewPlanUnitPrice() + PricePrice value = new Models::NewPlanGroupedAllocationPrice() { - Cadence = Models::NewPlanUnitPriceCadence.Annual, + Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - ModelType = Models::NewPlanUnitPriceModelType.Unit, + ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2956,40 +4129,28 @@ 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 NewPlanBulkWithProrationValidationWorks() { - PricePrice value = new Models::NewPlanTieredPrice() + PricePrice value = new Models::NewPlanBulkWithProrationPrice() { - Cadence = Models::NewPlanTieredPriceCadence.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::NewPlanTieredPriceModelType.Tiered, + ModelType = Models::NewPlanBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3018,27 +4179,28 @@ 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 NewPlanGroupedWithProratedMinimumValidationWorks() { - PricePrice value = new Models::NewPlanBulkPrice() + PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Models::NewPlanBulkPriceCadence.Annual, + Cadence = Models::NewPlanGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - ModelType = Models::NewPlanBulkPriceModelType.Bulk, + ModelType = + Models::NewPlanGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3068,34 +4230,37 @@ 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 NewPlanGroupedWithMeteredMinimumValidationWorks() { - PricePrice value = new BulkWithFilters() + PricePrice 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, @@ -3125,28 +4290,28 @@ 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 GroupedWithMinMaxThresholdsValidationWorks() { - PricePrice value = new Models::NewPlanPackagePrice() + PricePrice value = new GroupedWithMinMaxThresholds() { - Cadence = Models::NewPlanPackagePriceCadence.Annual, + Cadence = GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, 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() @@ -3175,32 +4340,34 @@ 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 NewPlanMatrixWithDisplayNameValidationWorks() { - PricePrice value = new Models::NewPlanMatrixPrice() + PricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() { - Cadence = Models::NewPlanMatrixPriceCadence.Annual, + Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MatrixWithDisplayNameConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], }, - ModelType = Models::NewPlanMatrixPriceModelType.Matrix, + ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3230,36 +4397,32 @@ 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 NewPlanGroupedTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanThresholdTotalAmountPrice() + PricePrice value = new Models::NewPlanGroupedTieredPackagePrice() { - Cadence = Models::NewPlanThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + Cadence = Models::NewPlanGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - ConsumptionTable = + GroupingKey = "x", + PackageSize = "package_size", + Tiers = [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], - Prorate = true, }, + ItemID = "item_id", + ModelType = Models::NewPlanGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3288,36 +4451,32 @@ 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 NewPlanMaxGroupTieredPackageValidationWorks() { - PricePrice value = new Models::NewPlanTieredPackagePrice() + PricePrice value = new Models::NewPlanMaxGroupTieredPackagePrice() { - Cadence = Models::NewPlanTieredPackagePriceCadence.Annual, + Cadence = Models::NewPlanMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + 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" }, ], }, + ModelType = Models::NewPlanMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3346,46 +4505,39 @@ 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 NewPlanScalableMatrixWithUnitPricingValidationWorks() { - PricePrice value = new Models::NewPlanTieredWithMinimumPrice() + PricePrice value = new Models::NewPlanScalableMatrixWithUnitPricingPrice() { - Cadence = Models::NewPlanTieredWithMinimumPriceCadence.Annual, + Cadence = Models::NewPlanScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanTieredWithMinimumPriceModelType.TieredWithMinimum, + ModelType = + Models::NewPlanScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - TieredWithMinimumConfig = new() + ScalableMatrixWithUnitPricingConfig = new() { - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - new() - { - MinimumAmount = "minimum_amount", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - HideZeroAmountTiers = true, + UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, + SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3415,36 +4567,42 @@ 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 NewPlanScalableMatrixWithTieredPricingValidationWorks() { - PricePrice value = new Models::NewPlanGroupedTieredPrice() + PricePrice value = new Models::NewPlanScalableMatrixWithTieredPricingPrice() { - Cadence = Models::NewPlanGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Models::NewPlanScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Models::NewPlanScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - GroupingKey = "x", + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], 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() @@ -3473,47 +4631,35 @@ public void NewPlanGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewPlanCumulativeGroupedBulkValidationWorks() { - PricePrice value = new Models::NewPlanTieredPackageWithMinimumPrice() + PricePrice value = new Models::NewPlanCumulativeGroupedBulkPrice() { - Cadence = Models::NewPlanTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Models::NewPlanTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + Cadence = Models::NewPlanCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - PackageSize = 0, - Tiers = + DimensionValues = [ new() { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", + 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() @@ -3542,33 +4688,28 @@ 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 CumulativeGroupedAllocationValidationWorks() { - PricePrice value = new Models::NewPlanPackageWithAllocationPrice() + PricePrice value = new CumulativeGroupedAllocation() { - Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -3597,28 +4738,29 @@ 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 DailyCreditAllowanceValidationWorks() { - PricePrice value = new Models::NewPlanUnitWithPercentPrice() + PricePrice value = new DailyCreditAllowance() { - Cadence = Models::NewPlanUnitWithPercentPriceCadence.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", - ModelType = Models::NewPlanUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3647,33 +4789,29 @@ 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 MeteredAllowanceValidationWorks() { - PricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + PricePrice value = new MeteredAllowance() { - Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + Cadence = MeteredAllowanceCadence.Annual, ItemID = "item_id", - MatrixWithAllocationConfig = new() + MeteredAllowanceConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3703,29 +4841,23 @@ 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 NewPlanMinimumCompositeValidationWorks() { - PricePrice value = new TieredWithProration() + PricePrice value = new Models::NewPlanMinimumCompositePrice() { - Cadence = TieredWithProrationCadence.Annual, + Cadence = Models::NewPlanMinimumCompositePriceCadence.Annual, ItemID = "item_id", + MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = Models::NewPlanMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3754,28 +4886,22 @@ 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 PercentValidationWorks() { - PricePrice value = new Models::NewPlanUnitWithProrationPrice() + PricePrice value = new Percent() { - Cadence = Models::NewPlanUnitWithProrationPriceCadence.Annual, + Cadence = PercentCadence.Annual, ItemID = "item_id", - ModelType = Models::NewPlanUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3804,32 +4930,26 @@ 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 EventOutputValidationWorks() { - PricePrice value = new Models::NewPlanGroupedAllocationPrice() + PricePrice value = new EventOutput() { - Cadence = Models::NewPlanGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = EventOutputCadence.Annual, + EventOutputConfig = new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = Models::NewPlanGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3859,33 +4979,23 @@ public void NewPlanGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewPlanBulkWithProrationSerializationRoundtripWorks() + public void NewPlanUnitSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanBulkWithProrationPrice() + PricePrice value = new Models::NewPlanUnitPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Models::NewPlanBulkWithProrationPriceCadence.Annual, + 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() @@ -3914,6 +5024,7 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3927,21 +5038,27 @@ public void NewPlanBulkWithProrationSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() + public void NewPlanTieredSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithProratedMinimumPrice() + PricePrice 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() @@ -3970,6 +5087,7 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3983,29 +5101,14 @@ public void NewPlanGroupedWithProratedMinimumSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void NewPlanBulkSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanGroupedWithMeteredMinimumPrice() + PricePrice 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, @@ -4035,6 +5138,7 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4048,18 +5152,20 @@ public void NewPlanGroupedWithMeteredMinimumSerializationRoundtripWorks() } [Fact] - public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { - PricePrice value = new GroupedWithMinMaxThresholds() + PricePrice 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", @@ -4090,6 +5196,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4103,26 +5210,70 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() } [Fact] - public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() + public void NewPlanPackageSerializationRoundtripWorks() { - PricePrice value = new Models::NewPlanMatrixWithDisplayNamePrice() + PricePrice value = new Models::NewPlanPackagePrice() { - Cadence = Models::NewPlanMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Models::NewPlanPackagePriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() + ModelType = Models::NewPlanPackagePriceModelType.Package, + Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, - ModelType = Models::NewPlanMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + 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, @@ -4152,6 +5303,7 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4165,24 +5317,23 @@ public void NewPlanMatrixWithDisplayNameSerializationRoundtripWorks() } [Fact] - public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() + public void NewPlanThresholdTotalAmountSerializationRoundtripWorks() { - 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() @@ -4211,6 +5362,7 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4224,24 +5376,23 @@ public void NewPlanGroupedTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() + public void NewPlanTieredPackageSerializationRoundtripWorks() { - 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() @@ -4270,6 +5421,7 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4283,30 +5435,33 @@ public void NewPlanMaxGroupTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void NewPlanTieredWithMinimumSerializationRoundtripWorks() { - 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, @@ -4336,6 +5491,7 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4349,34 +5505,23 @@ public void NewPlanScalableMatrixWithUnitPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void NewPlanGroupedTieredSerializationRoundtripWorks() { - 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() @@ -4405,6 +5550,7 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4418,27 +5564,34 @@ public void NewPlanScalableMatrixWithTieredPricingSerializationRoundtripWorks() } [Fact] - public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() + public void NewPlanTieredPackageWithMinimumSerializationRoundtripWorks() { - 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() @@ -4467,6 +5620,7 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4480,20 +5634,71 @@ public void NewPlanCumulativeGroupedBulkSerializationRoundtripWorks() } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void NewPlanPackageWithAllocationSerializationRoundtripWorks() { - PricePrice value = new CumulativeGroupedAllocation() + PricePrice value = new Models::NewPlanPackageWithAllocationPrice() { - Cadence = CumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Models::NewPlanPackageWithAllocationPriceCadence.Annual, + ItemID = "item_id", + ModelType = Models::NewPlanPackageWithAllocationPriceModelType.PackageWithAllocation, + Name = "Annual fee", + PackageWithAllocationConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", + 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() @@ -4522,6 +5727,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4535,146 +5741,2171 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void NewPlanMatrixWithAllocationSerializationRoundtripWorks() + { + PricePrice value = new Models::NewPlanMatrixWithAllocationPrice() + { + Cadence = Models::NewPlanMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }, + ModelType = Models::NewPlanMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredWithProrationSerializationRoundtripWorks() + { + PricePrice value = new 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() { - PricePrice value = new Minimum() - { - Cadence = MinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new Models::SharedUnitConversionRateConfig() - { - ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, + 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 NewPlanMinimumCompositeSerializationRoundtripWorks() + public void UnitValidationWorks() { - PricePrice value = new Models::NewPlanMinimumCompositePrice() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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", + ConversionRateType = Models::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() + { + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - PricePrice value = new Percent() + BulkWithFiltersConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { - 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", + 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 ); @@ -4683,52 +7914,24 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - PricePrice value = new EventOutput() + BulkWithFiltersConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { - 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", + ConversionRateType = 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 ); @@ -4737,25 +7940,19 @@ public void EventOutputSerializationRoundtripWorks() } } -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 +7981,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 +8002,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 +8023,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 +8043,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +8058,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 +8094,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 +8111,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 +8147,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 +8175,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 +8196,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 +8219,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +8234,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 +8270,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 +8281,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 +8313,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +8324,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 +8340,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 +8360,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -5225,6 +8387,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,67 +8398,165 @@ 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, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + Cadence = TieredWithProrationCadence.Annual, ItemID = "item_id", 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); + } - 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, - }; + [Fact] + public 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 + ); - model.Validate(); + 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 +8567,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 +8584,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 +8611,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 +8672,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"), + 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.NotNull(value); - Assert.Throws(() => value.Validate()); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } - [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) + [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>( - json, - ModelBase.SerializerOptions - ); + var model = new TieredWithProrationConfigTier + { + 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>( - 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); + 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 +8735,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 +8773,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 +8798,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 +8843,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 +8870,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 +8891,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 +8914,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +8929,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 +8969,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 +8986,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 +9026,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 +9060,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 +9081,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 +9107,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9122,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 +9162,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 +9173,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 +9209,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +9220,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 +9240,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 +9264,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6103,6 +9291,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +9302,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 +9326,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 +9417,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 +9439,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 +9499,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 +9594,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 +9613,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - TieredWithProrationConversionRateConfig value = + GroupedWithMinMaxThresholdsConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -6426,29 +9629,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 +9684,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 +9711,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 +9732,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 +9755,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9770,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 +9810,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 +9827,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 +9867,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 +9901,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 +9922,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 +9948,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9963,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 +10003,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 +10014,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 +10050,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10061,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 +10081,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 +10105,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6917,6 +10132,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10143,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 +10258,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 +10280,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 +10340,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 +10414,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7148,7 +10435,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7156,7 +10443,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7167,7 +10454,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - GroupedWithMinMaxThresholdsConversionRateConfig value = + CumulativeGroupedAllocationConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7184,7 +10471,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7193,20 +10480,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 +10526,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 +10552,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 +10573,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 +10593,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10608,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 +10649,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 +10666,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 +10707,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 +10740,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 +10761,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 +10784,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10799,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 +10840,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 +10851,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 +10888,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10899,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 +10920,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 +10945,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7675,6 +10972,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10983,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 +11008,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 +11100,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 +11123,72 @@ 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", - UnitAmount = "unit_amount", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; - string expectedGroupingKey = "x"; - string expectedUnitAmount = "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(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); - Assert.Equal(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + 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 CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - 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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7827,53 +11199,159 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - 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 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 expectedDailyAllowance = "daily_allowance"; + string expectedDefaultUnitAmount = "default_unit_amount"; + List expectedDimensions = ["string"]; + string expectedEventDayProperty = "x"; + List expectedMatrixValues = + [ + new() { DimensionValues = ["string"], 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(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 CumulativeGroupedAllocationConfig + var model = new DailyCreditAllowanceConfig { - 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" }], }; 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 CumulativeGroupedAllocationConversionRateConfigTest : TestBase +public class MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue { 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 MatrixValue { 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 MatrixValue { 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 MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7885,7 +11363,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7906,18 +11384,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 +11402,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -7941,26 +11418,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 +11474,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 +11500,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 +11521,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 +11541,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11556,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 +11598,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 +11615,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 +11657,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 +11690,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 +11711,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 +11734,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11749,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 +11791,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 +11802,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 +11840,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11851,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 +11873,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 +11899,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8372,6 +11926,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11937,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 +11963,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 +12056,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 +12079,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 +12093,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 +12148,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 +12199,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 +12230,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 +12301,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 +12321,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 +12338,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 +12353,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8691,6 +12401,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 +12440,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 +12460,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +12509,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 +12557,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 +12603,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 +12626,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +12675,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 +12716,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12759,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9065,6 +12786,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +12815,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 +12987,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 +13120,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 +13164,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 +13184,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +13238,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 +13294,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 +13345,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 +13368,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +13422,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 +13468,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +13521,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9756,6 +13548,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +13582,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 +13837,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 +14241,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 +14713,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..8f90eb15d 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,12 @@ public void MatrixWithAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1704,6 +1816,7 @@ public void TieredWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1724,6 +1837,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 +1883,12 @@ public void TieredWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1817,6 +1937,7 @@ public void UnitWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1837,6 +1958,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 +2002,12 @@ public void UnitWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -1928,6 +2056,7 @@ public void GroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -1954,6 +2083,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 +2126,12 @@ public void GroupedAllocationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2050,6 +2186,7 @@ public void BulkWithProrationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2070,6 +2207,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 +2250,12 @@ public void BulkWithProrationValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2160,6 +2304,7 @@ public void GroupedWithProratedMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2186,6 +2331,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 +2374,12 @@ public void GroupedWithProratedMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2276,6 +2428,7 @@ public void GroupedWithMeteredMinimumValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2311,6 +2464,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 +2507,12 @@ public void GroupedWithMeteredMinimumValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2401,6 +2561,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2428,6 +2589,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 +2632,12 @@ public void GroupedWithMinMaxThresholdsValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2518,6 +2686,7 @@ public void MatrixWithDisplayNameValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2538,6 +2707,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 +2763,12 @@ public void MatrixWithDisplayNameValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2641,6 +2817,7 @@ public void GroupedTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2671,6 +2848,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 +2891,12 @@ public void GroupedTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2761,6 +2945,7 @@ public void MaxGroupTieredPackageValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2781,6 +2966,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 +3019,12 @@ public void MaxGroupTieredPackageValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -2881,6 +3073,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -2901,6 +3094,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 +3145,7 @@ public void ScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2959,6 +3154,12 @@ public void ScalableMatrixWithUnitPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3007,6 +3208,7 @@ public void ScalableMatrixWithTieredPricingValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3027,6 +3229,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 +3291,12 @@ public void ScalableMatrixWithTieredPricingValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3136,6 +3345,7 @@ public void CumulativeGroupedBulkValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -3169,6 +3379,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 +3422,12 @@ public void CumulativeGroupedBulkValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3259,6 +3476,7 @@ public void CumulativeGroupedAllocationValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -3286,6 +3504,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 +3547,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 +3601,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 +3630,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,16 +3664,148 @@ 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 MeteredAllowanceValidationWorks() + { + Price value = 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", + }, }; value.Validate(); } @@ -3487,6 +3854,7 @@ public void MinimumCompositeValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3507,6 +3875,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() @@ -3550,6 +3919,12 @@ public void MinimumCompositeValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3598,6 +3973,7 @@ public void PercentValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3618,6 +3994,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() @@ -3661,6 +4038,12 @@ public void PercentValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3709,6 +4092,7 @@ public void EventOutputValidationWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3735,6 +4119,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 +4162,12 @@ public void EventOutputValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; value.Validate(); } @@ -3825,6 +4216,7 @@ public void UnitSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3845,6 +4237,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 +4281,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 +4338,7 @@ public void TieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -3959,6 +4359,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 +4415,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 +4473,7 @@ public void BulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4086,6 +4494,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 +4537,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 +4603,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4208,6 +4624,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 +4667,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 +4724,7 @@ public void PackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4321,6 +4745,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 +4789,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 +4846,7 @@ public void MatrixSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4435,6 +4867,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 +4916,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 +4973,7 @@ public void ThresholdTotalAmountSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4554,6 +4994,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 +5046,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 +5103,7 @@ public void TieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4676,6 +5124,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 +5176,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 +5233,7 @@ public void TieredWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4798,6 +5254,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 +5317,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 +5374,7 @@ public void GroupedTieredSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -4940,6 +5404,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 +5447,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 +5504,7 @@ public void TieredPackageWithMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5053,6 +5525,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 +5587,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 +5644,7 @@ public void PackageWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5185,6 +5665,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 +5714,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 +5771,7 @@ public void UnitWithPercentSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5304,6 +5792,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 +5836,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 +5893,7 @@ public void MatrixWithAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5418,6 +5914,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 +5964,12 @@ public void MatrixWithAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5518,6 +6021,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5538,6 +6042,7 @@ 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" }, Maximum = new() @@ -5583,6 +6088,12 @@ public void TieredWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5634,6 +6145,7 @@ public void UnitWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5654,6 +6166,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() @@ -5697,6 +6210,12 @@ public void UnitWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5748,6 +6267,7 @@ public void GroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5774,6 +6294,7 @@ public void GroupedAllocationSerializationRoundtripWorks() 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() @@ -5816,6 +6337,12 @@ public void GroupedAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5873,6 +6400,7 @@ public void BulkWithProrationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -5893,6 +6421,7 @@ public void BulkWithProrationSerializationRoundtripWorks() }, 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() @@ -5935,6 +6464,12 @@ public void BulkWithProrationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -5986,6 +6521,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6012,6 +6548,7 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -6054,6 +6591,12 @@ public void GroupedWithProratedMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6105,6 +6648,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6140,6 +6684,7 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() 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() @@ -6182,6 +6727,12 @@ public void GroupedWithMeteredMinimumSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6233,6 +6784,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6260,6 +6812,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() 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() @@ -6302,6 +6855,12 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6353,6 +6912,7 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6373,6 +6933,7 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() }, 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() @@ -6428,6 +6989,12 @@ public void MatrixWithDisplayNameSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6479,6 +7046,7 @@ public void GroupedTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6509,6 +7077,7 @@ public void GroupedTieredPackageSerializationRoundtripWorks() 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() @@ -6551,6 +7120,12 @@ public void GroupedTieredPackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6602,6 +7177,7 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6622,6 +7198,7 @@ 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() @@ -6674,6 +7251,12 @@ public void MaxGroupTieredPackageSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6725,6 +7308,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6745,6 +7329,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, 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() @@ -6795,6 +7380,7 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -6803,6 +7389,12 @@ public void ScalableMatrixWithUnitPricingSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6854,6 +7446,7 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -6874,6 +7467,7 @@ 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" }, Maximum = new() @@ -6935,6 +7529,12 @@ public void ScalableMatrixWithTieredPricingSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -6986,6 +7586,7 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -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() @@ -7061,6 +7663,12 @@ public void CumulativeGroupedBulkSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); @@ -7112,6 +7720,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -7139,6 +7748,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() @@ -7181,119 +7791,11 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void MinimumSerializationRoundtripWorks() - { - Price value = new PriceMinimum() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PriceMinimumBillingMode.InAdvance, - Cadence = PriceMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() + LicenseType = new() { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = 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(value, ModelBase.SerializerOptions); @@ -7303,21 +7805,21 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void MinimumCompositeSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - Price value = new MinimumComposite() + Price value = new DailyCreditAllowance() { ID = "id", BillableMetric = new("id"), BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = MinimumCompositeBillingMode.InAdvance, - Cadence = MinimumCompositeCadence.OneTime, + BillingMode = DailyCreditAllowanceBillingMode.InAdvance, + Cadence = DailyCreditAllowanceCadence.OneTime, CompositePriceFilters = [ new() { - Field = MinimumCompositeCompositePriceFilterField.PriceID, - Operator = MinimumCompositeCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ], @@ -7346,122 +7848,17 @@ public void MinimumCompositeSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() + DailyCreditAllowanceConfig = new() { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - MinimumCompositeConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "name", - PlanPhaseOrder = 0, - PriceType = MinimumCompositePriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - }, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize(element, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void PercentSerializationRoundtripWorks() - { - Price value = new Percent() - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = PercentBillingMode.InAdvance, - Cadence = PercentCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = PercentCompositePriceFilterField.PriceID, - Operator = PercentCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], + 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, @@ -7480,6 +7877,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 +7912,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 +7934,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 +7977,7 @@ public void EventOutputSerializationRoundtripWorks() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7592,14 +7996,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 +8017,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 +8043,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 +8107,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7716,6 +8128,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 +8162,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 +8351,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -7976,8 +8370,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 +8414,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 +8481,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8093,6 +8502,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 +8546,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 +8597,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -8205,6 +8618,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 +8667,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 +8761,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8362,6 +8782,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 +8826,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 +8884,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8474,6 +8905,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 +8944,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 +9171,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8582,6 +9192,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 +9231,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 +9291,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8689,6 +9312,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 +9351,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 +9403,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -8799,6 +9424,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 +9689,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 +10032,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 +10306,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 +10447,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9384,6 +10468,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 +10524,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 +10576,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9505,6 +10597,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 +10658,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 +10684,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 +10705,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 +10752,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9671,6 +10773,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 +10829,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 +10887,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -9798,6 +10908,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 +10964,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 +11020,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -9923,6 +11041,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 +11102,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 +11128,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 +11152,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -10072,6 +11199,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10092,6 +11220,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 +11276,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 +11331,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10216,6 +11352,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 +11407,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 +11455,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10336,6 +11476,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 +11576,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10455,6 +11597,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 +11650,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 +11703,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -10577,6 +11724,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 +11777,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 +12132,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 +12404,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 +12546,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11173,6 +12567,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 +12610,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 +12664,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11283,6 +12685,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 +12733,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 +12760,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 +12780,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 +12828,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11437,6 +12849,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 +12892,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 +12951,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11552,6 +12972,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 +13015,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 +13073,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -11666,6 +13094,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 +13142,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 +13169,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 +13192,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -11803,6 +13240,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11823,6 +13261,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 +13304,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 +13360,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -11935,6 +13381,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 +13423,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 +13472,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12043,6 +13493,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 +13581,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12150,6 +13602,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 +13642,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 +13696,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12260,6 +13717,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 +13757,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 +14100,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 +14372,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 +14522,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -12851,6 +14543,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 +14586,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 +14648,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -12969,6 +14669,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 +14718,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 +14745,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 +14765,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 +14821,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13132,6 +14842,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 +14885,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 +14955,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13258,6 +14976,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 +15019,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 +15088,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -13383,6 +15109,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 +15158,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 +15185,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 +15208,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -13529,6 +15264,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13549,6 +15285,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 +15328,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 +15392,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13669,6 +15413,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 +15455,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 +15512,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13785,6 +15533,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 +15629,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -13900,6 +15650,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 +15690,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 +15752,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14018,6 +15773,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 +15813,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 +16124,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 +16198,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 +16324,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 +16496,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 +16764,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 +16905,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -14886,6 +16926,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 +16970,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 +17022,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -14995,6 +17043,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 +17096,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 +17122,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 +17143,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 +17190,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15153,6 +17211,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 +17255,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 +17313,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15268,6 +17334,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 +17378,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 +17437,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -15384,6 +17458,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 +17511,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 +17537,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 +17561,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -15525,6 +17608,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15545,6 +17629,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 +17673,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 +17728,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15657,6 +17749,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 +17792,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 +17840,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15765,6 +17861,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 +17949,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15872,6 +17970,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 +18011,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 +18064,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -15982,6 +18085,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 +18126,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 +18469,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 +18739,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 +18880,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16563,6 +18901,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 +18950,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 +19002,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -16677,6 +19023,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 +19077,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 +19103,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 +19124,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 +19171,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16836,6 +19192,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 +19241,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 +19299,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -16956,6 +19320,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 +19369,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 +19425,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -17074,6 +19446,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 +19500,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 +19526,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 +19550,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -17216,6 +19597,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17236,6 +19618,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 +19667,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 +19722,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17353,6 +19743,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 +19791,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 +19839,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17466,6 +19860,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 +19953,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17578,6 +19974,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 +20020,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 +20073,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -17693,6 +20094,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 +20140,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 +20488,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 +20760,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 +20901,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18281,6 +20922,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 +20974,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 +21028,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18400,6 +21049,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 +21107,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 +21133,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 +21154,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 +21201,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18563,6 +21222,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 +21274,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 +21335,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18689,6 +21356,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 +21408,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 +21469,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -18815,6 +21490,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 +21548,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 +21574,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 +21598,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -18961,6 +21645,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -18981,6 +21666,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 +21718,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 +21773,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19101,6 +21794,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 +21845,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 +21893,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19217,6 +21914,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 +22010,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19332,6 +22031,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 +22080,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 +22133,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -19450,6 +22154,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 +22203,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 +22552,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 +22990,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 +23082,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 +23239,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20281,6 +23260,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 +23312,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 +23365,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20399,6 +23386,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 +23444,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 +23470,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 +23491,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 +23538,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20562,6 +23559,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 +23611,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 +23672,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20688,6 +23693,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 +23745,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 +23805,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -20813,6 +23826,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 +23884,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 +23910,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 +23934,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -20959,6 +23981,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -20979,6 +24002,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 +24054,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 +24109,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21099,6 +24130,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 +24181,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 +24229,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21215,6 +24250,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 +24346,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21330,6 +24367,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 +24416,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 +24469,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -21448,6 +24490,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 +24539,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 +24890,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 +25260,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 +25350,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 +25507,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22211,6 +25528,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 +25591,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 +25645,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22341,6 +25666,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 +25735,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 +25761,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 +25782,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 +25829,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22515,6 +25850,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 +25913,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 +25974,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22652,6 +25995,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 +26058,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 +26119,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -22789,6 +26140,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 +26209,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 +26235,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 +26259,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -22946,6 +26306,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -22966,6 +26327,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 +26390,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 +26402,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new TieredWithMinimum { @@ -23330,6 +26445,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23350,6 +26466,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 +26785,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 +26838,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -23479,6 +26859,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 +26919,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 +27279,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 +27831,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 +27940,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 +28098,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24450,6 +28128,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 +28171,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 +28224,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -24568,6 +28254,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 +28303,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 +28330,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 +28350,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 +28397,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24731,6 +28427,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 +28470,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 +28531,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -24857,6 +28561,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 +28604,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 +28664,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -24982,6 +28694,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 +28743,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 +28770,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 +28793,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -25119,6 +28840,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25148,6 +28870,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 +28913,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 +28968,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25268,6 +28998,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 +29040,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 +29088,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25384,6 +29118,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 +29205,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25499,6 +29235,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 +29275,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 +29328,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -25617,6 +29358,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 +29398,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 +29749,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 +30059,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 +30149,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 +30225,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 +30366,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26371,6 +30387,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 +30449,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 +30503,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26500,6 +30524,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 +30595,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 +30621,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 +30642,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 +30689,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26676,6 +30710,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 +30772,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 +30833,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -26812,6 +30854,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 +30916,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 +30977,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -26948,6 +30998,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 +31069,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 +31095,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 +31122,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -27110,6 +31169,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27130,6 +31190,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 +31252,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 +31307,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27260,6 +31328,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 +31389,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 +31437,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27386,6 +31458,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 +31564,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27511,6 +31585,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 +31644,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 +31697,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -27639,6 +31718,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 +31777,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 +32132,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 +32566,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 +32676,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 +32834,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28480,6 +32855,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 +32904,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 +32958,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -28596,6 +32979,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 +33036,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 +33062,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 +33083,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 +33130,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28758,6 +33151,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 +33200,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 +33261,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -28881,6 +33282,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 +33331,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 +33392,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -29004,6 +33413,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 +33470,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 +33496,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 +33520,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -29149,6 +33567,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29169,6 +33588,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 +33637,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 +33692,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29286,6 +33713,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 +33761,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 +33809,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29399,6 +33830,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 +33923,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29511,6 +33944,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 +33990,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 +34043,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -29626,6 +34064,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 +34110,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 +34454,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 +34746,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 +34821,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 +34962,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30290,6 +34983,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 +35027,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 +35080,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30400,6 +35101,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 +35155,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 +35181,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 +35202,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 +35249,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30559,6 +35270,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 +35314,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 +35375,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30677,6 +35396,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 +35440,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 +35500,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -30794,6 +35521,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 +35575,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 +35601,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 +35625,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -30936,6 +35672,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -30956,6 +35693,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 +35737,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 +35792,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31283,6 +35813,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 +36075,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 +36128,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -31393,6 +36149,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 +36190,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 +36533,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 +36871,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 +37028,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32044,6 +37049,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 +37099,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 +37153,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32161,6 +37174,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 +37230,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 +37256,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 +37277,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 +37324,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32322,6 +37345,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 +37395,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 +37456,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32446,6 +37477,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 +37527,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 +37588,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -32570,6 +37609,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 +37665,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 +37691,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 +37715,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -32714,6 +37762,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32734,6 +37783,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 +37833,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 +37888,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32852,6 +37909,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 +37958,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 +38006,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -32966,6 +38027,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 +38121,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33079,6 +38142,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 +38189,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 +38242,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33195,6 +38263,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 +38310,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 +38657,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationCompositePriceFilter + { + Field = MatrixWithAllocationCompositePriceFilterField.PriceID, + Operator = MatrixWithAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixWithAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithAllocationCompositePriceFilterFieldTest : TestBase @@ -33712,6 +38925,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MatrixWithAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixWithAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class TieredWithProrationTest : TestBase { [Fact] @@ -33758,6 +39066,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -33778,6 +39087,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() @@ -33823,6 +39133,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -33871,6 +39187,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -33891,6 +39208,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -33942,6 +39260,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -33962,6 +39286,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); @@ -33982,6 +39307,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -34028,6 +39354,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34048,6 +39375,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() @@ -34093,6 +39421,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -34148,6 +39482,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34168,6 +39503,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() @@ -34213,6 +39549,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -34268,6 +39610,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -34288,6 +39631,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -34339,6 +39683,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + TieredWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -34359,6 +39709,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); @@ -34382,6 +39733,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -34428,6 +39780,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34448,6 +39801,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() @@ -34493,6 +39847,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -34542,6 +39902,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34562,6 +39923,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() @@ -34606,6 +39968,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -34652,6 +40016,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34672,6 +40037,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() @@ -34761,6 +40127,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34781,6 +40148,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() @@ -34823,10 +40191,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ), DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -34873,6 +40244,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -34893,6 +40265,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() @@ -34935,10 +40308,135 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProration + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = TieredWithProrationBillingMode.InAdvance, + Cadence = TieredWithProrationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 @@ -35153,6 +40651,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationCompositePriceFilter + { + Field = TieredWithProrationCompositePriceFilterField.PriceID, + Operator = TieredWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + TieredWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCompositePriceFilterFieldTest : TestBase @@ -35482,6 +40995,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationTieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + TieredWithProrationTieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationTieredWithProrationConfigTierTest : TestBase @@ -35556,6 +41082,115 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + TieredWithProrationTieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class TieredWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new TieredWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + TieredWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationTest : TestBase @@ -35604,6 +41239,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35624,6 +41260,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() @@ -35667,6 +41304,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -35715,6 +41358,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -35735,6 +41379,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -35786,6 +41431,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -35806,6 +41457,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); @@ -35826,6 +41478,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedUnitWithProrationConfig, model.UnitWithProrationConfig); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -35872,6 +41525,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -35892,6 +41546,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() @@ -35935,6 +41590,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -35990,6 +41651,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36010,6 +41672,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() @@ -36053,6 +41716,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -36108,6 +41777,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -36128,6 +41798,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -36179,6 +41850,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + UnitWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -36199,6 +41876,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); @@ -36222,6 +41900,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -36268,6 +41947,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36288,6 +41968,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() @@ -36331,6 +42012,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -36380,6 +42067,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36400,6 +42088,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() @@ -36442,6 +42131,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -36488,6 +42179,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36508,6 +42200,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() @@ -36595,6 +42288,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36615,6 +42309,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() @@ -36655,10 +42350,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -36705,6 +42403,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -36725,6 +42424,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() @@ -36765,10 +42465,133 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() UnitWithProrationConfig = new("unit_amount"), DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProration + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = UnitWithProrationBillingMode.InAdvance, + Cadence = UnitWithProrationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 UnitWithProrationBillingModeTest : TestBase @@ -36983,6 +42806,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationCompositePriceFilter + { + Field = UnitWithProrationCompositePriceFilterField.PriceID, + Operator = UnitWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + UnitWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class UnitWithProrationCompositePriceFilterFieldTest : TestBase @@ -37286,6 +43124,111 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationUnitWithProrationConfig { UnitAmount = "unit_amount" }; + + UnitWithProrationUnitWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class UnitWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new UnitWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + UnitWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationTest : TestBase @@ -37334,6 +43277,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37360,6 +43304,7 @@ public void FieldRoundtrip_Works() 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() @@ -37402,6 +43347,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -37450,6 +43401,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37476,6 +43428,7 @@ public void FieldRoundtrip_Works() GroupingKey = "x", OverageUnitRate = "overage_unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -37524,6 +43477,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -37545,6 +43504,7 @@ public void FieldRoundtrip_Works() 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); @@ -37564,6 +43524,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -37610,6 +43571,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37636,6 +43598,7 @@ public void SerializationRoundtrip_Works() 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() @@ -37678,6 +43641,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -37733,6 +43702,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -37759,6 +43729,7 @@ public void FieldRoundtripThroughSerialization_Works() 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() @@ -37801,6 +43772,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -37856,6 +43833,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -37882,6 +43860,7 @@ public void FieldRoundtripThroughSerialization_Works() GroupingKey = "x", OverageUnitRate = "overage_unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -37930,6 +43909,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -37951,6 +43936,7 @@ public void FieldRoundtripThroughSerialization_Works() 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); @@ -37973,6 +43959,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -38019,6 +44006,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38045,6 +44033,7 @@ public void Validation_Works() 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() @@ -38087,6 +44076,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -38136,6 +44131,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38162,6 +44158,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() 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() @@ -38203,6 +44200,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -38249,6 +44248,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38275,6 +44275,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() 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() @@ -38361,6 +44362,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38387,6 +44389,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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() @@ -38426,10 +44429,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -38476,6 +44482,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -38502,6 +44509,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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() @@ -38541,10 +44549,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocation + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedAllocationBillingMode.InAdvance, + Cadence = GroupedAllocationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, + 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 GroupedAllocationBillingModeTest : TestBase @@ -38759,6 +44895,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationCompositePriceFilter + { + Field = GroupedAllocationCompositePriceFilterField.PriceID, + Operator = GroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationCompositePriceFilterFieldTest : TestBase @@ -39030,6 +45181,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationGroupedAllocationConfig + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }; + + GroupedAllocationGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedAllocationPriceTypeTest : TestBase @@ -39092,6 +45258,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class BulkWithProrationTest : TestBase { [Fact] @@ -39144,6 +45405,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39164,6 +45426,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() @@ -39206,6 +45469,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -39260,6 +45529,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39280,6 +45550,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -39328,6 +45599,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -39349,6 +45626,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); @@ -39368,6 +45646,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -39420,6 +45699,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39440,6 +45720,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() @@ -39482,6 +45763,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -39543,6 +45830,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39563,6 +45851,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() @@ -39605,6 +45894,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -39666,6 +45961,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -39686,6 +45982,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -39734,6 +46031,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + BulkWithProrationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -39755,6 +46058,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); @@ -39777,6 +46081,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -39829,6 +46134,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39849,6 +46155,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() @@ -39891,6 +46198,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -39946,6 +46259,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -39966,6 +46280,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() @@ -40007,6 +46322,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -40059,6 +46376,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40079,6 +46397,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() @@ -40171,6 +46490,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40191,6 +46511,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() @@ -40230,10 +46551,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -40286,6 +46610,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -40306,6 +46631,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() @@ -40345,10 +46671,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProration + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = BulkWithProrationBillingMode.InAdvance, + BulkWithProrationConfig = new( + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ] + ), + Cadence = BulkWithProrationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 BulkWithProrationBillingModeTest : TestBase @@ -40501,6 +46955,23 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationBulkWithProrationConfig + { + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + BulkWithProrationBulkWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationBulkWithProrationConfigTierTest : TestBase @@ -40617,6 +47088,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationBulkWithProrationConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + BulkWithProrationBulkWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationCadenceTest : TestBase @@ -40775,6 +47260,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationCompositePriceFilter + { + Field = BulkWithProrationCompositePriceFilterField.PriceID, + Operator = BulkWithProrationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + BulkWithProrationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class BulkWithProrationCompositePriceFilterFieldTest : TestBase @@ -41028,6 +47528,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class BulkWithProrationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new BulkWithProrationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + BulkWithProrationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithProratedMinimumTest : TestBase { [Fact] @@ -41074,6 +47669,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41100,6 +47696,7 @@ public void FieldRoundtrip_Works() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41142,6 +47739,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -41190,6 +47793,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41217,6 +47821,7 @@ public void FieldRoundtrip_Works() Minimum = "minimum", UnitRate = "unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -41267,6 +47872,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithProratedMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -41291,6 +47902,7 @@ public void FieldRoundtrip_Works() expectedGroupedWithProratedMinimumConfig, model.GroupedWithProratedMinimumConfig ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -41310,6 +47922,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -41356,6 +47969,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41382,6 +47996,7 @@ public void SerializationRoundtrip_Works() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41424,6 +48039,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -41479,6 +48100,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41505,6 +48127,7 @@ public void FieldRoundtripThroughSerialization_Works() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41547,6 +48170,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -41602,6 +48231,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -41629,6 +48259,7 @@ public void FieldRoundtripThroughSerialization_Works() Minimum = "minimum", UnitRate = "unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -41679,6 +48310,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithProratedMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -41703,6 +48340,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedGroupedWithProratedMinimumConfig, deserialized.GroupedWithProratedMinimumConfig ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -41725,6 +48363,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -41771,6 +48410,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -41797,6 +48437,7 @@ public void Validation_Works() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -41839,238 +48480,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new GroupedWithProratedMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() + LicenseType = new() { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new GroupedWithProratedMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, - Cadence = GroupedWithProratedMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithProratedMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new GroupedWithProratedMinimum { @@ -42113,6 +48535,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42139,6 +48562,238 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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() @@ -42178,10 +48833,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -42228,6 +48886,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42254,6 +48913,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Minimum = "minimum", UnitRate = "unit_rate", }, + InvoiceGroupingKey = "invoice_grouping_key", InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, Item = new() { ID = "id", Name = "name" }, Maximum = new() @@ -42293,10 +48953,138 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithProratedMinimumBillingMode.InAdvance, + Cadence = GroupedWithProratedMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, + 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 @@ -42509,6 +49297,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumCompositePriceFilter + { + Field = GroupedWithProratedMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithProratedMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithProratedMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumCompositePriceFilterFieldTest : TestBase @@ -42790,6 +49593,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumGroupedWithProratedMinimumConfig + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }; + + GroupedWithProratedMinimumGroupedWithProratedMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithProratedMinimumPriceTypeTest : TestBase @@ -42848,6 +49666,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithProratedMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithProratedMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithProratedMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithMeteredMinimumTest : TestBase { [Fact] @@ -42894,6 +49807,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -42929,6 +49843,7 @@ public void FieldRoundtrip_Works() 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() @@ -42971,6 +49886,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -43019,6 +49940,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43055,6 +49977,7 @@ public void FieldRoundtrip_Works() new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -43105,6 +50028,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMeteredMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -43129,6 +50058,7 @@ public void FieldRoundtrip_Works() expectedGroupedWithMeteredMinimumConfig, model.GroupedWithMeteredMinimumConfig ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -43148,6 +50078,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -43194,6 +50125,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43229,6 +50161,7 @@ public void SerializationRoundtrip_Works() 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() @@ -43271,6 +50204,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -43326,6 +50265,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43361,6 +50301,7 @@ public void FieldRoundtripThroughSerialization_Works() 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() @@ -43403,6 +50344,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -43458,6 +50405,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -43494,6 +50442,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -43544,6 +50493,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMeteredMinimumLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -43568,6 +50523,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedGroupedWithMeteredMinimumConfig, deserialized.GroupedWithMeteredMinimumConfig ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -43590,6 +50546,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -43636,6 +50593,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -43671,6 +50629,7 @@ public void Validation_Works() 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() @@ -43713,256 +50672,19 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new GroupedWithMeteredMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, - ], - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", - }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", - }; - - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new GroupedWithMeteredMinimum - { - ID = "id", - BillableMetric = new("id"), - BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, - Cadence = GroupedWithMeteredMinimumCadence.OneTime, - CompositePriceFilters = - [ - new() - { - Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, - Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, - Values = ["string"], - }, - ], - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - CreditAllocation = new() - { - AllowsRollover = true, - Currency = "currency", - CustomExpiration = new() - { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - Filters = - [ - new() - { - Field = Field.PriceID, - Operator = Operator.Includes, - Values = ["string"], - }, - ], - }, - Currency = "currency", - Discount = new PercentageDiscount() - { - DiscountType = PercentageDiscountDiscountType.Percentage, - PercentageDiscountValue = 0.15, - AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], - Filters = - [ - new() - { - Field = PercentageDiscountFilterField.PriceID, - Operator = PercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - Reason = "reason", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - GroupedWithMeteredMinimumConfig = new() + LicenseType = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, - ], - }, - InvoicingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, - Item = new() { ID = "id", Name = "name" }, - Maximum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MaximumFilterField.PriceID, - Operator = MaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - MaximumAmount = "maximum_amount", - }, - MaximumAmount = "maximum_amount", - Metadata = new Dictionary() { { "foo", "string" } }, - Minimum = new() - { - AppliesToPriceIds = ["string"], - Filters = - [ - new() - { - Field = MinimumFilterField.PriceID, - Operator = MinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - MinimumAmount = "minimum_amount", + ID = "id", + GroupingKey = "grouping_key", + Name = "name", }, - MinimumAmount = "minimum_amount", - Name = "name", - PlanPhaseOrder = 0, - PriceType = GroupedWithMeteredMinimumPriceType.UsagePrice, - ReplacesPriceID = "replaces_price_id", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = new GroupedWithMeteredMinimum { @@ -44005,6 +50727,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44040,6 +50763,256 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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() @@ -44079,10 +51052,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -44129,6 +51105,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -44164,6 +51141,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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() @@ -44203,10 +51181,147 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimum + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithMeteredMinimumBillingMode.InAdvance, + Cadence = GroupedWithMeteredMinimumCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedWithMeteredMinimumConfig = new() + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }, + ], + }, + 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 @@ -44419,6 +51534,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumCompositePriceFilter + { + Field = GroupedWithMeteredMinimumCompositePriceFilterField.PriceID, + Operator = GroupedWithMeteredMinimumCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithMeteredMinimumCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumCompositePriceFilterFieldTest : TestBase @@ -44762,6 +51892,27 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig + { + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = + [ + new() { ScalingFactor = "scaling_factor", ScalingValue = "scaling_value" }, + ], + ScalingKey = "scaling_key", + UnitAmounts = [new() { PricingValue = "pricing_value", UnitAmount = "unit_amount" }], + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactorTest : TestBase @@ -44836,6 +51987,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor + { + ScalingFactor = "scaling_factor", + ScalingValue = "scaling_value", + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmountTest : TestBase @@ -44910,6 +52075,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount + { + PricingValue = "pricing_value", + UnitAmount = "unit_amount", + }; + + GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMeteredMinimumPriceTypeTest : TestBase @@ -44970,6 +52149,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithMeteredMinimumLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMeteredMinimumLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithMeteredMinimumLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedWithMinMaxThresholdsTest : TestBase { [Fact] @@ -45016,6 +52290,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45043,6 +52318,7 @@ public void FieldRoundtrip_Works() 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() @@ -45085,6 +52361,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -45133,6 +52415,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45160,6 +52443,7 @@ public void FieldRoundtrip_Works() MinimumCharge = "minimum_charge", PerUnitRate = "per_unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -45210,6 +52494,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMinMaxThresholdsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -45234,6 +52524,7 @@ public void FieldRoundtrip_Works() expectedGroupedWithMinMaxThresholdsConfig, model.GroupedWithMinMaxThresholdsConfig ); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); Assert.Equal(expectedItem, model.Item); Assert.Equal(expectedMaximum, model.Maximum); @@ -45253,6 +52544,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -45299,6 +52591,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45326,6 +52619,7 @@ public void SerializationRoundtrip_Works() 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() @@ -45368,6 +52662,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -45423,6 +52723,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45450,6 +52751,7 @@ public void FieldRoundtripThroughSerialization_Works() 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() @@ -45492,6 +52794,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -45547,6 +52855,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -45574,6 +52883,7 @@ public void FieldRoundtripThroughSerialization_Works() MinimumCharge = "minimum_charge", PerUnitRate = "per_unit_rate", }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -45624,6 +52934,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedWithMinMaxThresholdsLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -45648,6 +52964,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedGroupedWithMinMaxThresholdsConfig, deserialized.GroupedWithMinMaxThresholdsConfig ); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); Assert.Equal(expectedItem, deserialized.Item); Assert.Equal(expectedMaximum, deserialized.Maximum); @@ -45670,6 +52987,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -45716,6 +53034,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45743,6 +53062,7 @@ public void Validation_Works() 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() @@ -45785,6 +53105,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -45834,6 +53160,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45861,6 +53188,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() 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() @@ -45902,6 +53230,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -45948,6 +53278,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -45975,6 +53306,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() 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() @@ -46061,6 +53393,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46088,6 +53421,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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() @@ -46127,10 +53461,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -46177,6 +53514,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46204,6 +53542,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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() @@ -46243,10 +53582,139 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholds + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedWithMinMaxThresholdsBillingMode.InAdvance, + Cadence = GroupedWithMinMaxThresholdsCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + 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 = GroupedWithMinMaxThresholdsPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsBillingModeTest : TestBase @@ -46459,6 +53927,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsCompositePriceFilter + { + Field = GroupedWithMinMaxThresholdsCompositePriceFilterField.PriceID, + Operator = GroupedWithMinMaxThresholdsCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedWithMinMaxThresholdsCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCompositePriceFilterFieldTest : TestBase @@ -46746,6 +54229,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsPriceTypeTest : TestBase @@ -46804,6 +54303,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedWithMinMaxThresholdsLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedWithMinMaxThresholdsLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MatrixWithDisplayNameTest : TestBase { [Fact] @@ -46850,6 +54444,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -46870,6 +54465,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" }, MatrixWithDisplayNameConfig = new() @@ -46925,6 +54521,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -46973,6 +54575,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -46993,6 +54596,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -47056,6 +54660,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithDisplayNameLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -47076,6 +54686,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(expectedMatrixWithDisplayNameConfig, model.MatrixWithDisplayNameConfig); @@ -47096,6 +54707,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -47142,6 +54754,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47162,6 +54775,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" }, MatrixWithDisplayNameConfig = new() @@ -47217,6 +54831,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -47272,6 +54892,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47292,6 +54913,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" }, MatrixWithDisplayNameConfig = new() @@ -47347,6 +54969,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -47402,6 +55030,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -47422,6 +55051,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -47485,6 +55115,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MatrixWithDisplayNameLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -47505,6 +55141,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(expectedMatrixWithDisplayNameConfig, deserialized.MatrixWithDisplayNameConfig); @@ -47528,6 +55165,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -47574,6 +55212,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47594,6 +55233,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" }, MatrixWithDisplayNameConfig = new() @@ -47649,6 +55289,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -47698,6 +55344,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47718,6 +55365,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" }, MatrixWithDisplayNameConfig = new() @@ -47772,6 +55420,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -47818,6 +55468,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47838,6 +55489,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" }, MatrixWithDisplayNameConfig = new() @@ -47937,6 +55589,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -47957,6 +55610,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" }, MatrixWithDisplayNameConfig = new() @@ -48009,10 +55663,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -48059,6 +55716,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48079,6 +55737,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" }, MatrixWithDisplayNameConfig = new() @@ -48131,10 +55790,145 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayName + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MatrixWithDisplayNameBillingMode.InAdvance, + Cadence = MatrixWithDisplayNameCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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", + }, + }; + + MatrixWithDisplayName copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameBillingModeTest : TestBase @@ -48347,6 +56141,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameCompositePriceFilter + { + Field = MatrixWithDisplayNameCompositePriceFilterField.PriceID, + Operator = MatrixWithDisplayNameCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MatrixWithDisplayNameCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameCompositePriceFilterFieldTest : TestBase @@ -48672,6 +56481,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfig + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }; + + MatrixWithDisplayNameMatrixWithDisplayNameConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmountTest : TestBase @@ -48754,6 +56585,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }; + + MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount copied = new(model); + + Assert.Equal(model, copied); + } } public class MatrixWithDisplayNamePriceTypeTest : TestBase @@ -48814,6 +56660,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MatrixWithDisplayNameLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixWithDisplayNameLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MatrixWithDisplayNameLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class GroupedTieredPackageTest : TestBase { [Fact] @@ -48860,6 +56801,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -48890,6 +56832,7 @@ public void FieldRoundtrip_Works() 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() @@ -48932,6 +56875,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -48980,6 +56929,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49010,6 +56960,7 @@ public void FieldRoundtrip_Works() new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -49058,6 +57009,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -49079,6 +57036,7 @@ public void FieldRoundtrip_Works() 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(expectedMaximum, model.Maximum); @@ -49098,6 +57056,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -49144,6 +57103,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49174,6 +57134,7 @@ public void SerializationRoundtrip_Works() 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() @@ -49216,6 +57177,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -49271,6 +57238,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49301,6 +57269,7 @@ public void FieldRoundtripThroughSerialization_Works() 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() @@ -49343,6 +57312,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -49398,6 +57373,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -49428,6 +57404,7 @@ public void FieldRoundtripThroughSerialization_Works() new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, ], }; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -49476,6 +57453,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + GroupedTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -49497,6 +57480,7 @@ public void FieldRoundtripThroughSerialization_Works() 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(expectedMaximum, deserialized.Maximum); @@ -49519,6 +57503,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -49565,6 +57550,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49595,6 +57581,7 @@ public void Validation_Works() 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() @@ -49637,6 +57624,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -49686,6 +57679,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49716,6 +57710,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() 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() @@ -49757,6 +57752,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -49803,6 +57800,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49833,6 +57831,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() 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() @@ -49919,6 +57918,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -49949,6 +57949,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() 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() @@ -49988,10 +57989,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -50038,6 +58042,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50068,6 +58073,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() 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() @@ -50107,10 +58113,142 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackage + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = GroupedTieredPackageBillingMode.InAdvance, + Cadence = GroupedTieredPackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + GroupedTieredPackageConfig = new() + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, + 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 = GroupedTieredPackagePriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + GroupedTieredPackage copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageBillingModeTest : TestBase @@ -50325,6 +58463,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageCompositePriceFilter + { + Field = GroupedTieredPackageCompositePriceFilterField.PriceID, + Operator = GroupedTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + GroupedTieredPackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageCompositePriceFilterFieldTest : TestBase @@ -50632,6 +58785,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageGroupedTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }; + + GroupedTieredPackageGroupedTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackageGroupedTieredPackageConfigTierTest : TestBase @@ -50706,6 +58878,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageGroupedTieredPackageConfigTier + { + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }; + + GroupedTieredPackageGroupedTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedTieredPackagePriceTypeTest : TestBase @@ -50766,6 +58952,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class GroupedTieredPackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + GroupedTieredPackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class MaxGroupTieredPackageTest : TestBase { [Fact] @@ -50812,6 +59093,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -50832,6 +59114,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" }, MaxGroupTieredPackageConfig = new() @@ -50884,6 +59167,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -50932,6 +59221,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -50952,6 +59242,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -51012,6 +59303,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MaxGroupTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -51032,6 +59329,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(expectedMaxGroupTieredPackageConfig, model.MaxGroupTieredPackageConfig); @@ -51052,6 +59350,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -51098,6 +59397,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51118,6 +59418,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" }, MaxGroupTieredPackageConfig = new() @@ -51170,6 +59471,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -51225,6 +59532,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51245,6 +59553,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" }, MaxGroupTieredPackageConfig = new() @@ -51297,6 +59606,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -51352,6 +59667,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -51372,6 +59688,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -51432,6 +59749,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + MaxGroupTieredPackageLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -51452,6 +59775,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(expectedMaxGroupTieredPackageConfig, deserialized.MaxGroupTieredPackageConfig); @@ -51475,6 +59799,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -51521,6 +59846,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51541,6 +59867,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" }, MaxGroupTieredPackageConfig = new() @@ -51593,6 +59920,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -51642,6 +59975,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51662,6 +59996,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" }, MaxGroupTieredPackageConfig = new() @@ -51713,6 +60048,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -51759,6 +60096,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51779,6 +60117,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" }, MaxGroupTieredPackageConfig = new() @@ -51875,6 +60214,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -51895,6 +60235,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" }, MaxGroupTieredPackageConfig = new() @@ -51944,10 +60285,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -51994,6 +60338,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52014,6 +60359,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" }, MaxGroupTieredPackageConfig = new() @@ -52063,10 +60409,142 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackage + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = MaxGroupTieredPackageBillingMode.InAdvance, + Cadence = MaxGroupTieredPackageCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 MaxGroupTieredPackageBillingModeTest : TestBase @@ -52279,6 +60757,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageCompositePriceFilter + { + Field = MaxGroupTieredPackageCompositePriceFilterField.PriceID, + Operator = MaxGroupTieredPackageCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + MaxGroupTieredPackageCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageCompositePriceFilterFieldTest : TestBase @@ -52588,6 +61081,25 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfig + { + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + }; + + MaxGroupTieredPackageMaxGroupTieredPackageConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackageMaxGroupTieredPackageConfigTierTest : TestBase @@ -52662,6 +61174,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageMaxGroupTieredPackageConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + MaxGroupTieredPackageMaxGroupTieredPackageConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class MaxGroupTieredPackagePriceTypeTest : TestBase @@ -52722,6 +61248,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class MaxGroupTieredPackageLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MaxGroupTieredPackageLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + MaxGroupTieredPackageLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class ScalableMatrixWithUnitPricingTest : TestBase { [Fact] @@ -52768,6 +61389,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -52788,6 +61410,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() @@ -52838,6 +61461,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -52846,6 +61470,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -52894,6 +61524,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -52914,6 +61545,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -52973,6 +61605,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -52981,6 +61614,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithUnitPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -53001,6 +61640,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); @@ -53024,6 +61664,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithUnitPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -53070,6 +61711,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53090,6 +61732,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() @@ -53140,6 +61783,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53148,6 +61792,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -53203,6 +61853,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53223,6 +61874,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() @@ -53273,6 +61925,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53281,6 +61934,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -53336,6 +61995,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -53356,6 +62016,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -53415,6 +62076,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -53423,6 +62085,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + ScalableMatrixWithUnitPricingLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -53443,6 +62111,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); @@ -53469,6 +62138,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -53515,6 +62185,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53535,6 +62206,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() @@ -53585,6 +62257,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53593,6 +62266,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -53642,6 +62321,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53662,6 +62342,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() @@ -53712,6 +62393,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53719,6 +62401,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -53765,6 +62449,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53785,6 +62470,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() @@ -53835,6 +62521,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -53887,6 +62574,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -53907,6 +62595,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() @@ -53957,15 +62646,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -54012,6 +62705,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -54032,6 +62726,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() @@ -54082,15 +62777,155 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithUnitPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithUnitPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 = ScalableMatrixWithUnitPricingPriceType.UsagePrice, + ReplacesPriceID = "replaces_price_id", + ScalableMatrixWithUnitPricingConfig = new() + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + ScalableMatrixWithUnitPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingBillingModeTest : TestBase @@ -54305,6 +63140,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingCompositePriceFilter + { + Field = ScalableMatrixWithUnitPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithUnitPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ScalableMatrixWithUnitPricingCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingCompositePriceFilterFieldTest : TestBase @@ -54582,6 +63432,7 @@ public void FieldRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54597,6 +63448,7 @@ public void FieldRoundtrip_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -54607,6 +63459,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedMatrixScalingFactors[i], model.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, model.UnitPrice); + Assert.Equal(expectedGroupingKey, model.GroupingKey); Assert.Equal(expectedProrate, model.Prorate); Assert.Equal(expectedSecondDimension, model.SecondDimension); } @@ -54627,6 +63480,7 @@ public void SerializationRoundtrip_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54657,6 +63511,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54680,6 +63535,7 @@ public void FieldRoundtripThroughSerialization_Works() }, ]; string expectedUnitPrice = "unit_price"; + string expectedGroupingKey = "x"; bool expectedProrate = true; string expectedSecondDimension = "second_dimension"; @@ -54690,6 +63546,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedMatrixScalingFactors[i], deserialized.MatrixScalingFactors[i]); } Assert.Equal(expectedUnitPrice, deserialized.UnitPrice); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); Assert.Equal(expectedProrate, deserialized.Prorate); Assert.Equal(expectedSecondDimension, deserialized.SecondDimension); } @@ -54710,6 +63567,7 @@ public void Validation_Works() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }; @@ -54735,6 +63593,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() UnitPrice = "unit_price", }; + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.False(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -54779,10 +63639,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); Assert.Null(model.Prorate); Assert.True(model.RawData.ContainsKey("prorate")); Assert.Null(model.SecondDimension); @@ -54806,12 +63669,39 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ], UnitPrice = "unit_price", + GroupingKey = null, Prorate = null, SecondDimension = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactorTest @@ -54957,6 +63847,118 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithUnitPricingLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithUnitPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + ScalableMatrixWithUnitPricingLicenseType copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingTest : TestBase @@ -55005,6 +64007,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55025,6 +64028,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() @@ -55086,6 +64090,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -55134,6 +64144,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55154,6 +64165,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -55224,6 +64236,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); @@ -55244,6 +64262,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); @@ -55267,6 +64286,7 @@ public void FieldRoundtrip_Works() model.ScalableMatrixWithTieredPricingConfig ); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -55313,6 +64333,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55333,6 +64354,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() @@ -55394,6 +64416,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -55449,6 +64477,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55469,6 +64498,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() @@ -55530,6 +64560,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -55585,6 +64621,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -55605,6 +64642,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -55675,6 +64713,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); @@ -55695,6 +64739,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); @@ -55721,6 +64766,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -55767,6 +64813,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55787,6 +64834,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() @@ -55848,6 +64896,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -55897,6 +64951,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -55917,6 +64972,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() @@ -55977,6 +65033,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -56023,6 +65081,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56043,6 +65102,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() @@ -56148,6 +65208,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56168,6 +65229,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() @@ -56226,10 +65288,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -56276,6 +65341,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -56296,6 +65362,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() @@ -56354,10 +65421,151 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() }, DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricing + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = ScalableMatrixWithTieredPricingBillingMode.InAdvance, + Cadence = ScalableMatrixWithTieredPricingCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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", + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + ScalableMatrixWithTieredPricing copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingBillingModeTest : TestBase @@ -56572,6 +65780,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingCompositePriceFilter + { + Field = ScalableMatrixWithTieredPricingCompositePriceFilterField.PriceID, + Operator = ScalableMatrixWithTieredPricingCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ScalableMatrixWithTieredPricingCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingCompositePriceFilterFieldTest : TestBase @@ -57117,6 +66340,34 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig + { + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], + SecondDimension = "second_dimension", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactorTest @@ -57262,6 +66513,23 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor copied = + new(model); + + Assert.Equal(model, copied); + } } public class ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTierTest : TestBase @@ -57336,6 +66604,117 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class ScalableMatrixWithTieredPricingLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new ScalableMatrixWithTieredPricingLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + ScalableMatrixWithTieredPricingLicenseType copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkTest : TestBase @@ -57384,6 +66763,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57417,6 +66797,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() @@ -57459,6 +66840,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -57507,6 +66894,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -57540,6 +66928,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -57590,6 +66979,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedBulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -57611,6 +67006,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); @@ -57630,6 +67026,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -57676,6 +67073,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57709,6 +67107,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() @@ -57751,6 +67150,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -57806,6 +67211,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -57839,6 +67245,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() @@ -57881,6 +67288,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -57936,6 +67349,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedBulkCumulativeGroupedBulkConfig expectedCumulativeGroupedBulkConfig = new() { @@ -57969,6 +67383,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -58019,6 +67434,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedBulkLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -58040,6 +67461,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); @@ -58062,6 +67484,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -58108,6 +67531,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58141,6 +67565,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() @@ -58183,6 +67608,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -58232,6 +67663,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58265,6 +67697,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() @@ -58306,6 +67739,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -58352,6 +67787,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58385,6 +67821,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() @@ -58471,6 +67908,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58504,6 +67942,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() @@ -58543,10 +67982,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -58593,6 +68035,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedBulkConfig = new() { @@ -58626,6 +68069,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() @@ -58665,10 +68109,145 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulk + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedBulkBillingMode.InAdvance, + Cadence = CumulativeGroupedBulkCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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 = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, + }; + + CumulativeGroupedBulk copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkBillingModeTest : TestBase @@ -58881,6 +68460,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCompositePriceFilter + { + Field = CumulativeGroupedBulkCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedBulkCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + CumulativeGroupedBulkCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkCompositePriceFilterFieldTest : TestBase @@ -59206,6 +68800,28 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfig + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }; + + CumulativeGroupedBulkCumulativeGroupedBulkConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValueTest : TestBase @@ -59288,6 +68904,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedBulkPriceTypeTest : TestBase @@ -59348,6 +68979,101 @@ public void InvalidEnumSerializationRoundtrip_Works() } } +public class CumulativeGroupedBulkLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedBulkLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + CumulativeGroupedBulkLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + public class CumulativeGroupedAllocationTest : TestBase { [Fact] @@ -59394,6 +69120,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59421,6 +69148,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() @@ -59463,6 +69191,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string expectedID = "id"; @@ -59511,6 +69245,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -59538,6 +69273,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -59588,6 +69324,12 @@ public void FieldRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, model.ID); Assert.Equal(expectedBillableMetric, model.BillableMetric); @@ -59612,6 +69354,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); @@ -59631,6 +69374,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedPriceType, model.PriceType); Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedLicenseType, model.LicenseType); } [Fact] @@ -59677,6 +69421,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59704,6 +69449,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() @@ -59746,6 +69492,12 @@ public void SerializationRoundtrip_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -59801,6 +69553,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -59828,6 +69581,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() @@ -59870,6 +69624,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); @@ -59925,6 +69685,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; CumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = new() { @@ -59952,6 +69713,7 @@ public void FieldRoundtripThroughSerialization_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -60002,6 +69764,12 @@ public void FieldRoundtripThroughSerialization_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }; + CumulativeGroupedAllocationLicenseType expectedLicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; Assert.Equal(expectedID, deserialized.ID); Assert.Equal(expectedBillableMetric, deserialized.BillableMetric); @@ -60026,6 +69794,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); @@ -60048,6 +69817,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -60094,6 +69864,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60121,6 +69892,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() @@ -60163,6 +69935,12 @@ public void Validation_Works() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", }, + LicenseType = new() + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }, }; model.Validate(); @@ -60212,6 +69990,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60239,6 +70018,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() @@ -60280,6 +70060,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.Null(model.DimensionalPriceConfiguration); Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.False(model.RawData.ContainsKey("license_type")); } [Fact] @@ -60326,6 +70108,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60353,6 +70136,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() @@ -60439,6 +70223,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60466,6 +70251,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() @@ -60505,10 +70291,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; Assert.Null(model.DimensionalPriceConfiguration); Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.LicenseType); + Assert.True(model.RawData.ContainsKey("license_type")); } [Fact] @@ -60555,6 +70344,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, CumulativeGroupedAllocationConfig = new() { @@ -60582,6 +70372,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() @@ -60621,10 +70412,139 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() ReplacesPriceID = "replaces_price_id", DimensionalPriceConfiguration = null, + LicenseType = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + ID = "id", + BillableMetric = new("id"), + BillingCycleConfiguration = new() { Duration = 0, DurationUnit = DurationUnit.Day }, + BillingMode = CumulativeGroupedAllocationBillingMode.InAdvance, + Cadence = CumulativeGroupedAllocationCadence.OneTime, + CompositePriceFilters = + [ + new() + { + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + CreatedAt = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), + CreditAllocation = new() + { + AllowsRollover = true, + Currency = "currency", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + Filters = + [ + new() + { + Field = Field.PriceID, + Operator = Operator.Includes, + Values = ["string"], + }, + ], + LicenseTypeID = "license_type_id", + }, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + Discount = new PercentageDiscount() + { + DiscountType = PercentageDiscountDiscountType.Percentage, + PercentageDiscountValue = 0.15, + AppliesToPriceIds = ["h74gfhdjvn7ujokd", "7hfgtgjnbvc3ujkl"], + Filters = + [ + new() + { + Field = PercentageDiscountFilterField.PriceID, + Operator = PercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + Reason = "reason", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + 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", + }, + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationBillingModeTest : TestBase @@ -60837,6 +70757,21 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationCompositePriceFilter + { + Field = CumulativeGroupedAllocationCompositePriceFilterField.PriceID, + Operator = CumulativeGroupedAllocationCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + CumulativeGroupedAllocationCompositePriceFilter copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCompositePriceFilterFieldTest : TestBase @@ -61124,6 +71059,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationPriceTypeTest : TestBase @@ -61182,24 +71133,119 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class PriceMinimumTest : TestBase +public class CumulativeGroupedAllocationLicenseTypeTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, model.ID); + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedName, model.Name); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + string expectedGroupingKey = "grouping_key"; + string expectedName = "name"; + + Assert.Equal(expectedID, deserialized.ID); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedName, deserialized.Name); + } + + [Fact] + public void Validation_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationLicenseType + { + ID = "id", + GroupingKey = "grouping_key", + Name = "name", + }; + + CumulativeGroupedAllocationLicenseType copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = 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"], }, ], @@ -61228,8 +71274,17 @@ public void FieldRoundtrip_Works() 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, @@ -61248,6 +71303,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() @@ -61281,16 +71337,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 = 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"; @@ -61300,20 +71361,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = DurationUnit.Day, }; - ApiEnum expectedBillingMode = - PriceMinimumBillingMode.InAdvance; - ApiEnum expectedCadence = PriceMinimumCadence.OneTime; - List expectedCompositePriceFilters = + ApiEnum expectedBillingMode = + DailyCreditAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.OneTime; + List expectedCompositePriceFilters = [ new() { - Field = PriceMinimumCompositePriceFilterField.PriceID, - Operator = PriceMinimumCompositePriceFilterOperator.Includes, + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, Values = ["string"], }, ]; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -61338,8 +71400,17 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; SharedDiscount expectedDiscount = new PercentageDiscount() { DiscountType = PercentageDiscountDiscountType.Percentage, @@ -61358,6 +71429,7 @@ public void FieldRoundtrip_Works() }; string expectedExternalPriceID = "external_price_id"; double expectedFixedPriceQuantity = 0; + string expectedInvoiceGroupingKey = "invoice_grouping_key"; BillingCycleConfiguration expectedInvoicingCycleConfiguration = new() { Duration = 0, @@ -61395,21 +71467,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("daily_credit_allowance"); string expectedName = "name"; long expectedPlanPhaseOrder = 0; - ApiEnum expectedPriceType = PriceMinimumPriceType.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); @@ -61427,9 +71501,11 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedCreatedAt, model.CreatedAt); Assert.Equal(expectedCreditAllocation, model.CreditAllocation); 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); @@ -61443,31 +71519,164 @@ public void FieldRoundtrip_Works() } 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 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", + }, + }; + + string json = 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 { 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"], }, ], @@ -61496,8 +71705,17 @@ public void SerializationRoundtrip_Works() 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, @@ -61516,6 +71734,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() @@ -61549,138 +71768,2306 @@ 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 = 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( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = + DailyCreditAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + DailyCreditAllowanceConversionRateConfig 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"; + DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; + 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("daily_credit_allowance"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + 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); + 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(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); + 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 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", + }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + 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 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = 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 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 = 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 DailyCreditAllowanceBillingModeTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [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; + + string json = JsonSerializer.Serialize(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 DailyCreditAllowanceCadenceTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [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.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; + + 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 DailyCreditAllowanceCompositePriceFilterTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new DailyCreditAllowanceCompositePriceFilter + { + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.Includes, + Values = ["string"], + }; + + ApiEnum expectedField = + DailyCreditAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + DailyCreditAllowanceCompositePriceFilterOperator.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 DailyCreditAllowanceCompositePriceFilter + { + Field = DailyCreditAllowanceCompositePriceFilterField.PriceID, + Operator = DailyCreditAllowanceCompositePriceFilterOperator.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 DailyCreditAllowanceCompositePriceFilter + { + 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 = + DailyCreditAllowanceCompositePriceFilterField.PriceID; + ApiEnum expectedOperator = + DailyCreditAllowanceCompositePriceFilterOperator.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 DailyCreditAllowanceCompositePriceFilter + { + 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 DailyCreditAllowanceCompositePriceFilterFieldTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [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; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class DailyCreditAllowanceCompositePriceFilterOperatorTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Includes)] + [InlineData(DailyCreditAllowanceCompositePriceFilterOperator.Excludes)] + public void SerializationRoundtrip_Works( + DailyCreditAllowanceCompositePriceFilterOperator rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class DailyCreditAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + DailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + DailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + 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 + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + 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 + ); + + 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 DailyCreditAllowancePriceTypeTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [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; + + string json = JsonSerializer.Serialize(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 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 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 expectedID = "id"; + BillableMetricTiny expectedBillableMetric = new("id"); + BillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = DurationUnit.Day, + }; + ApiEnum expectedBillingMode = + MeteredAllowanceBillingMode.InAdvance; + ApiEnum expectedCadence = MeteredAllowanceCadence.OneTime; + List expectedCompositePriceFilters = + [ + new() + { + Field = MeteredAllowanceCompositePriceFilterField.PriceID, + Operator = MeteredAllowanceCompositePriceFilterOperator.Includes, + Values = ["string"], + }, + ]; + double expectedConversionRate = 0; + MeteredAllowanceConversionRateConfig 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" } }; + MeteredAllowanceConfig expectedMeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + 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("metered_allowance"); + string expectedName = "name"; + long expectedPlanPhaseOrder = 0; + 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); + 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(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(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); + 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 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 = 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", }, - }; - - string json = 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 +74080,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 +74118,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -61751,6 +74139,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 +74162,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 +74186,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 +74223,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 +74235,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 +74247,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 +74294,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -61912,6 +74315,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 +74334,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 +74358,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 +74381,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 +74422,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62024,6 +74443,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 +74462,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 +74486,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 +74542,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62132,6 +74563,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 +74582,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 +74606,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 +74618,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 +74659,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62239,6 +74680,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 +74699,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 +74723,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 +74782,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -62349,6 +74803,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 +74822,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 +74846,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 +75014,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 +75033,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 +75047,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 +75076,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 +75099,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 +75113,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 +75143,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 +75162,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 +75194,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 +75239,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 +75247,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 +75269,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 +75296,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 +75304,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 +75323,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 +75350,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -62761,13 +75370,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 +75387,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceMinimumConversionRateConfig value = new SharedTieredConversionRateConfig() + MeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, TieredConfig = new( @@ -62793,7 +75402,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -62802,27 +75411,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 +75466,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 +75517,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 +75548,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 +75629,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 +75649,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 +75663,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 +75804,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63030,6 +75825,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 +75869,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 +75922,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -63140,6 +75943,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 +75997,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 +76023,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 +76044,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 +76091,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63299,6 +76112,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 +76156,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 +76217,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63417,6 +76238,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 +76282,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 +76342,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -63534,6 +76363,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 +76417,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 +76443,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 +76467,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -63676,6 +76514,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63696,6 +76535,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 +76579,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 +76634,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63808,6 +76655,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 +76698,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 +76746,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -63916,6 +76767,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 +76855,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 +76991,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 +77032,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 +77082,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64133,6 +77103,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 +77142,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 +77375,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 +77699,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 +77775,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 +77916,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -64830,6 +77937,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 +77981,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 +78033,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -64939,6 +78054,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 +78103,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 +78129,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 +78150,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 +78197,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65093,6 +78218,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 +78262,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 +78320,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65208,6 +78341,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 +78385,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 +78444,7 @@ public void FieldRoundtripThroughSerialization_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -65324,6 +78465,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 +78514,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 +78540,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 +78564,7 @@ public void FieldRoundtripThroughSerialization_Works() expectedDimensionalPriceConfiguration, deserialized.DimensionalPriceConfiguration ); + Assert.Equal(expectedLicenseType, deserialized.LicenseType); } [Fact] @@ -65461,6 +78611,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65481,6 +78632,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 +78676,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 +78731,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65593,6 +78752,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 +78795,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 +78843,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65701,6 +78864,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 +78952,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65808,6 +78973,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 +79014,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 +79067,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -65918,6 +79088,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 +79129,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 +79472,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 +79732,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 +79804,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 +79945,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66557,6 +79972,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 +80015,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 +80068,7 @@ public void FieldRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }; string expectedCurrency = "currency"; SharedDiscount expectedDiscount = new PercentageDiscount() @@ -66672,6 +80095,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 +80143,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 +80170,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 +80190,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 +80237,7 @@ public void SerializationRoundtrip_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -66831,6 +80264,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 +80307,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 +80368,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 +80697,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 +80740,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 +80795,7 @@ public void Validation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67238,6 +80822,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 +80860,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 +80912,7 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67355,6 +80939,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 +80979,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 +81026,7 @@ public void OptionalNullablePropertiesUnsetValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67468,6 +81053,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 +81091,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 +81146,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67580,6 +81173,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 +81213,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 +81263,7 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() Values = ["string"], }, ], + LicenseTypeID = "license_type_id", }, Currency = "currency", Discount = new PercentageDiscount() @@ -67695,6 +81290,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 +81328,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 +81561,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 +81897,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 +81973,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..9b0abc839 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,7 @@ public void NewFloatingMatrixWithAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -889,6 +957,7 @@ public void NewFloatingTieredWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -932,6 +1001,7 @@ public void NewFloatingUnitWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -980,6 +1050,7 @@ public void NewFloatingGroupedAllocationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1028,6 +1099,7 @@ public void NewFloatingBulkWithProrationPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1077,6 +1149,7 @@ public void NewFloatingGroupedWithProratedMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1135,6 +1208,7 @@ public void NewFloatingGroupedWithMeteredMinimumPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1183,6 +1257,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1239,6 +1314,7 @@ public void NewFloatingMatrixWithDisplayNamePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1291,6 +1367,7 @@ public void NewFloatingGroupedTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1344,6 +1421,7 @@ public void NewFloatingMaxGroupTieredPackagePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1373,6 +1451,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -1403,6 +1482,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1465,6 +1545,7 @@ public void NewFloatingScalableMatrixWithTieredPricingPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1521,6 +1602,7 @@ public void NewFloatingCumulativeGroupedBulkPriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1569,20 +1651,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 +1752,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1654,6 +1796,7 @@ public void NewFloatingMinimumCompositePriceValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1696,6 +1839,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1743,6 +1887,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1786,6 +1931,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 +1990,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 +2037,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 +2091,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 +2138,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 +2190,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 +2245,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 +2300,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 +2366,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 +2421,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 +2487,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 +2540,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 +2587,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 +2640,7 @@ public void NewFloatingMatrixWithAllocationPriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -2530,6 +2689,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 +2736,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 +2788,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 +2840,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 +2893,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 +2955,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 +3007,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 +3067,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 +3123,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 +3180,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 +3213,7 @@ public void NewFloatingScalableMatrixWithUnitPricingPriceSerializationRoundtripW }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3074,6 +3244,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 +3310,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 +3370,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 +3422,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() + { + 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" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3258,14 +3485,22 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - 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, @@ -3294,6 +3529,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); @@ -3340,6 +3576,7 @@ public void NewFloatingMinimumCompositePriceSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3385,6 +3622,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3435,6 +3673,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3491,6 +3730,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3536,6 +3776,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 +3795,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +3851,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3666,6 +3909,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3718,6 +3962,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 +3984,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +4040,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -3840,6 +4087,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +4145,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -3919,6 +4169,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +4204,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 +4376,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 +4444,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 +4548,16 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Tier { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }; + + Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -4403,6 +4748,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4449,6 +4795,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -4470,6 +4817,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -4523,6 +4871,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4578,6 +4927,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4631,6 +4981,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -4655,6 +5006,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -4708,6 +5060,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4752,6 +5105,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -4804,6 +5159,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4827,6 +5183,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -4858,45 +5216,98 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} - -public class GroupedWithMinMaxThresholdsCadenceTest : TestBase -{ - [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Quarterly)] - [InlineData(GroupedWithMinMaxThresholdsCadence.OneTime)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Custom)] - public void Validation_Works(GroupedWithMinMaxThresholdsCadence rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize>( - JsonSerializer.SerializeToElement("invalid value"), - ModelBase.SerializerOptions - ); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(GroupedWithMinMaxThresholdsCadence.Annual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.SemiAnnual)] - [InlineData(GroupedWithMinMaxThresholdsCadence.Monthly)] + 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)] @@ -5015,6 +5426,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -5145,6 +5572,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5191,6 +5619,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -5212,6 +5641,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5265,6 +5695,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5320,6 +5751,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5373,6 +5805,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -5397,6 +5830,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5450,6 +5884,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5494,6 +5929,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5546,6 +5983,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5569,6 +6007,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5600,11 +6040,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocation + { + Cadence = CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -5757,6 +6250,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -5764,7 +6273,939 @@ public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase [Fact] public void UnitValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + 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, + 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" } }, + }; + + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 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(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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = 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, + 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(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + DailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + 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"), + }; + Models::NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 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(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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = 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 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 = 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 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 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 MatrixValueTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new MatrixValue { 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 MatrixValue { 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 MatrixValue { 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 MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new MatrixValue { DimensionValues = ["string"], UnitAmount = "unit_amount" }; + + MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + DailyCreditAllowanceConversionRateConfig value = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5776,7 +7217,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5797,18 +7238,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 +7256,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - CumulativeGroupedAllocationConversionRateConfig value = + DailyCreditAllowanceConversionRateConfig value = new Models::SharedTieredConversionRateConfig() { ConversionRateType = Models::ConversionRateType.Tiered, @@ -5832,27 +7272,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 +7328,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 +7354,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 +7374,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 +7393,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +7407,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 +7449,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 +7465,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 +7507,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 +7540,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 +7560,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 +7582,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +7596,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 +7638,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6158,12 +7648,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 +7685,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +7694,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 +7717,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 +7743,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6250,6 +7767,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +7776,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 +7802,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 +7893,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 +7916,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 +7930,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 +7985,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 +8036,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 +8067,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 +8138,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 +8158,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 +8175,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 +8190,7 @@ public void TieredSerializationRoundtripWorks() ), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6566,6 +8238,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6603,6 +8276,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 +8295,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +8343,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6714,6 +8390,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6758,6 +8435,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 +8457,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +8505,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6864,6 +8544,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +8586,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6927,6 +8610,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +8637,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 +8807,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 +8940,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7240,6 +8983,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 +9002,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9055,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7364,6 +9110,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7413,6 +9160,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 +9182,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9235,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7529,6 +9279,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +9331,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7602,6 +9355,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +9387,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 +9640,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..4f9802051 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,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1665,6 +1904,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1708,6 +1948,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1756,6 +1997,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1804,6 +2046,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1853,6 +2096,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1911,6 +2155,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1959,6 +2204,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2015,6 +2261,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2067,6 +2314,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2120,6 +2368,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2149,6 +2398,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2179,6 +2429,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2492,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2549,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2345,20 +2598,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() + { + 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" } }, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void MeteredAllowanceValidationWorks() { - 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, @@ -2387,6 +2699,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2430,6 +2743,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2472,6 +2786,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2519,6 +2834,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2562,6 +2878,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 +2937,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 +2984,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 +3038,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 +3085,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 +3137,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 +3192,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 +3247,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 +3313,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 +3368,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 +3434,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 +3487,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 +3534,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 +3587,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3306,6 +3636,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 +3683,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 +3735,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 +3787,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 +3840,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 +3902,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 +3954,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 +4014,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 +4070,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 +4127,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 +4160,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3850,6 +4191,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 +4257,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 +4317,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 +4369,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 +4432,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 +4476,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 +4523,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 +4569,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 +4620,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 +4677,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4313,6 +4724,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 +4743,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +4799,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4443,6 +4857,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4496,6 +4911,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 +4933,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +4989,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4618,6 +5036,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +5094,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -4697,6 +5118,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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,17 +5153,72 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} -public class PriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void CopyConstructor_Works() + { + var model = new 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 +{ + [Fact] + public void FieldRoundtrip_Works() { var model = new PriceBulkWithFiltersBulkWithFiltersConfig { @@ -4853,6 +5331,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 +5423,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 +5561,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceBulkWithFiltersCadenceTest : TestBase @@ -5245,6 +5769,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5292,6 +5817,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -5313,6 +5839,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5366,6 +5893,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5421,6 +5949,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5475,6 +6004,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -5499,6 +6029,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -5552,6 +6083,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5596,6 +6128,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -5648,6 +6182,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5671,6 +6206,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5702,11 +6239,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholds + { + Cadence = PriceGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -5859,6 +6449,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -5989,6 +6595,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6036,6 +6643,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6057,6 +6665,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6110,6 +6719,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6165,6 +6775,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6219,6 +6830,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6243,6 +6855,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6296,6 +6909,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6340,6 +6954,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6392,6 +7008,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6415,6 +7032,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6446,11 +7065,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocation + { + Cadence = PriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceCumulativeGroupedAllocationCadenceTest : TestBase @@ -6603,6 +7275,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -6688,17 +7376,24 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceMinimumTest : TestBase +public class PriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceMinimum + var model = 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, @@ -6727,18 +7422,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 = + PriceDailyCreditAllowanceCadence.Annual; string expectedCurrency = "currency"; + PriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6748,7 +7449,7 @@ public void FieldRoundtrip_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6768,12 +7469,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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); 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); @@ -6786,6 +7488,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +7502,19 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceMinimum + var model = 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, @@ -6833,11 +7543,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 +7559,19 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceMinimum + var model = 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, @@ -6882,25 +7600,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 = + PriceDailyCreditAllowanceCadence.Annual; string expectedCurrency = "currency"; + PriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - PriceMinimumMinimumConfig expectedMinimumConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -6910,7 +7634,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new Models::SharedUnitConversionRateConfig() { ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6930,12 +7654,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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); 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); @@ -6951,6 +7676,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +7690,19 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceMinimum + var model = 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, @@ -6998,6 +7731,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7007,12 +7741,19 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceMinimum + var model = 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", }; @@ -7036,6 +7777,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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,13 +7786,982 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceMinimum + var model = new PriceDailyCreditAllowance { - Cadence = PriceMinimumCadence.Annual, + Cadence = PriceDailyCreditAllowanceCadence.Annual, Currency = "currency", - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", + 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 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 = 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 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 = 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 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 PriceDailyCreditAllowanceCadenceTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), + ModelBase.SerializerOptions + ); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [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; + + string json = JsonSerializer.Serialize(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 PriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new PriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + 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", + }; + + 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 PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceDailyCreditAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceDailyCreditAllowanceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceDailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceDailyCreditAllowanceConversionRateConfig value = + new Models::SharedUnitConversionRateConfig() + { + ConversionRateType = Models::SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + PriceDailyCreditAllowanceConversionRateConfig value = + new Models::SharedTieredConversionRateConfig() + { + ConversionRateType = Models::ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PriceMeteredAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum expectedCadence = + PriceMeteredAllowanceCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + PriceMeteredAllowanceMeteredAllowanceConfig 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; + PriceMeteredAllowanceConversionRateConfig 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(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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + PriceMeteredAllowanceCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + PriceMeteredAllowanceMeteredAllowanceConfig 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; + PriceMeteredAllowanceConversionRateConfig 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(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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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 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", }; model.Validate(); @@ -7058,12 +8770,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 +8796,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7099,6 +8820,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +8829,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 +8855,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 +8946,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 +8968,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 +9036,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 +9087,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 +9118,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 +9229,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 +9293,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7468,6 +9331,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 +9350,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9398,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7582,6 +9448,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7626,6 +9493,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 +9515,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9563,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7732,6 +9602,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +9644,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7795,6 +9668,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +9695,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 +9865,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 +9998,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8108,6 +10041,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 +10060,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10113,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8232,6 +10168,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8281,6 +10218,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 +10240,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10293,7 @@ public void Validation_Works() Duration = 0, DurationUnit = Models::NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8397,6 +10337,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +10389,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8470,6 +10413,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +10445,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 +10698,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..ce01cf50d 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,6 +2166,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1936,6 +2213,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -1980,6 +2258,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2029,6 +2308,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2078,6 +2358,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2128,6 +2409,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2191,6 +2473,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2241,6 +2524,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2297,6 +2581,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2350,6 +2635,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2403,6 +2689,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2433,6 +2720,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -2463,6 +2751,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2526,6 +2815,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2582,6 +2872,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2632,21 +2923,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 +3031,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2723,6 +3080,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2766,6 +3124,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2815,6 +3174,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2858,6 +3218,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 +3281,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 +3332,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 +3392,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 +3443,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 +3499,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 +3559,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 +3619,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 +3690,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 +3750,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 +3821,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 +3878,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 +3930,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 +3991,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -3671,6 +4045,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 +4097,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 +4154,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 +4211,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 +4269,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 +4340,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 +4398,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 +4462,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 +4523,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 +4584,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 +4622,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4268,6 +4653,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 +4724,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 +4788,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 +4846,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4471,15 +4860,86 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = - new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance() { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void MeteredAllowanceSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPrice value = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance() + { + 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 +4968,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 +5024,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 +5075,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 +5132,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 +5194,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4780,6 +5245,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 +5264,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +5321,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4913,6 +5381,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -4971,6 +5440,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 +5462,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +5519,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5095,6 +5567,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +5627,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5176,6 +5651,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -5210,11 +5687,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters + { + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersCadence.Annual, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTest @@ -5340,6 +5873,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 +5972,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 +6121,22 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFiltersCadenceTest @@ -5779,6 +6364,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5829,6 +6415,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -5850,6 +6437,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -5905,6 +6493,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5963,6 +6552,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6021,6 +6611,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6045,6 +6636,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6100,6 +6692,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6146,6 +6739,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6202,6 +6797,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6225,6 +6821,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6258,11 +6856,67 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds + { + Cadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsCadenceTest @@ -6467,6 +7121,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigTest @@ -6601,6 +7273,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6651,6 +7324,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6672,6 +7346,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6727,6 +7402,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6785,6 +7461,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6843,6 +7520,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6867,6 +7545,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6922,6 +7601,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6968,6 +7648,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7024,6 +7706,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7047,6 +7730,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7080,56 +7765,112 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } -} - -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadenceTest - : TestBase -{ - [Theory] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Annual - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.SemiAnnual - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Monthly - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Quarterly - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.OneTime - )] - [InlineData( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence.Custom - )] - public void Validation_Works( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() + public void CopyConstructor_Works() { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + 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()); @@ -7289,6 +8030,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigTest @@ -7375,17 +8134,25 @@ public void TieredSerializationRoundtripWorks() } } -public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumTest : TestBase +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7414,19 +8181,27 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual; string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7436,7 +8211,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7456,12 +8231,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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); 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); @@ -7474,6 +8250,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +8264,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7521,12 +8306,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 +8323,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7571,12 +8365,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 +8379,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > expectedCadence = - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual; string expectedCurrency = "currency"; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = + new() + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; string expectedItemID = "item_id"; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7601,7 +8403,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig expectedConversionRateConfig = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7621,12 +8423,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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); 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); @@ -7642,6 +8445,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +8459,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -7689,6 +8501,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7698,12 +8511,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -7727,6 +8548,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +8557,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -7749,12 +8580,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -7767,6 +8606,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7790,6 +8630,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +8639,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum + var model = new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance { - Cadence = PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -7815,29 +8665,1141 @@ 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 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" } }, + }; + + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance copied = new( + model + ); + + Assert.Equal(model, copied); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceTest + : TestBase +{ + [Theory] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom + )] + public void Validation_Works( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime + )] + [InlineData( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom + )] + public void SerializationRoundtrip_Works( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + 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", + }; + + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig 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() + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + 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; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig 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(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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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 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" } }, + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_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" } }, + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > expectedCadence = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual; + string expectedCurrency = "currency"; + string expectedItemID = "item_id"; + 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; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig 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(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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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 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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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 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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = 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 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 = 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 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 +9807,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 +9818,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 +9857,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 +9933,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 +9987,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 +10020,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 +10097,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8055,7 +10118,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8063,7 +10126,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8074,7 +10137,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value = + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8091,7 +10154,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8139,6 +10202,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8181,6 +10245,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 +10264,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10312,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8296,6 +10363,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8346,6 +10414,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 +10436,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10484,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8452,6 +10523,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +10565,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8515,6 +10589,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +10616,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 +10802,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 +10947,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8856,6 +10995,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 +11014,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11067,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8981,6 +11123,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9036,6 +11179,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 +11201,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11254,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9152,6 +11298,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +11350,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9225,6 +11374,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -9255,11 +11406,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 +11682,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..55ccde388 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,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3419,6 +3978,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3464,6 +4024,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3514,6 +4075,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3564,6 +4126,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3616,6 +4179,7 @@ public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3681,6 +4245,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3730,6 +4295,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3787,6 +4353,7 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3841,6 +4408,7 @@ public void NewSubscriptionGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3895,6 +4463,7 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3926,6 +4495,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3957,6 +4527,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4022,6 +4593,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4079,6 +4651,7 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4128,6 +4701,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 +4760,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 +4804,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4216,6 +4850,7 @@ public void NewSubscriptionMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4259,6 +4894,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4307,6 +4943,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4351,6 +4988,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4413,6 +5051,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4463,6 +5102,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4520,6 +5160,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4570,6 +5211,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4625,6 +5267,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4684,6 +5327,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4742,6 +5386,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4812,6 +5457,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4870,6 +5516,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4940,6 +5587,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4996,6 +5644,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5046,6 +5695,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5103,6 +5753,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5154,6 +5805,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5205,6 +5857,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5261,6 +5914,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5317,6 +5971,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5375,6 +6030,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5446,6 +6102,7 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5501,6 +6158,7 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5564,6 +6222,7 @@ public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5624,6 +6283,7 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5684,6 +6344,7 @@ public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5721,6 +6382,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -5752,6 +6414,7 @@ public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWo Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5823,6 +6486,7 @@ public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtrip Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5886,6 +6550,7 @@ public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -5941,6 +6606,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 +6677,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 +6721,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6041,6 +6773,7 @@ public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6090,6 +6823,7 @@ public void PercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6144,6 +6878,7 @@ public void EventOutputSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6204,6 +6939,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6250,6 +6986,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 +7006,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +7063,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6383,6 +7122,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6436,6 +7176,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 +7199,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +7256,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -6562,6 +7305,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +7364,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -6645,6 +7391,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,64 +7428,120 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } -} - -public class BulkWithFiltersConfigTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::BulkWithFiltersConfig - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; - - Assert.Equal(expectedFilters.Count, model.Filters.Count); - for (int i = 0; i < expectedFilters.Count; i++) - { - Assert.Equal(expectedFilters[i], model.Filters[i]); - } - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } - } [Fact] - public void SerializationRoundtrip_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::BulkWithFiltersConfig + var model = new Subscriptions::BulkWithFilters { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; - + BulkWithFiltersConfig = new() + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }, + Cadence = 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 +{ + [Fact] + public void FieldRoundtrip_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" }, + ], + }; + + 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::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, @@ -6804,6 +7608,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 +7682,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 +7808,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Tier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::Tier copied = new(model); + + Assert.Equal(model, copied); + } } public class CadenceTest : TestBase @@ -7162,6 +8008,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7203,6 +8050,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7222,6 +8070,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7272,6 +8121,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7324,6 +8174,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7372,6 +8223,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -7394,6 +8246,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7444,6 +8297,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7486,6 +8340,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7531,6 +8387,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7557,6 +8414,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -7586,12 +8445,62 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithProration + { + Cadence = Subscriptions::TieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::TieredWithProration copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationCadenceTest : TestBase @@ -7732,6 +8641,19 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithProrationConfig + { + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + }; + + Subscriptions::TieredWithProrationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConfigTierTest : TestBase @@ -7804,6 +8726,20 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::TieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::TieredWithProrationConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class TieredWithProrationConversionRateConfigTest : TestBase @@ -7934,6 +8870,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7982,6 +8919,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8004,6 +8942,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8058,6 +8997,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8114,6 +9054,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8169,6 +9110,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8194,6 +9136,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8248,6 +9191,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8294,6 +9238,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8347,6 +9293,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8373,6 +9320,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8406,12 +9355,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::GroupedWithMinMaxThresholds + { + Cadence = Subscriptions::GroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::GroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class GroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -8566,19 +9569,35 @@ public void Validation_Works() model.Validate(); } -} -public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase -{ [Fact] - public void UnitValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + var model = new Subscriptions::GroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::GroupedWithMinMaxThresholdsConfig copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class GroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::GroupedWithMinMaxThresholdsConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; value.Validate(); } @@ -8696,6 +9715,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8744,6 +9764,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8766,6 +9787,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8820,6 +9842,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8876,6 +9899,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8931,6 +9955,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; @@ -8956,6 +9981,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -9010,6 +10036,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9056,6 +10083,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9109,6 +10138,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9135,6 +10165,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9168,12 +10200,66 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::CumulativeGroupedAllocation + { + Cadence = Subscriptions::CumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::CumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationCadenceTest : TestBase @@ -9328,6 +10414,22 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::CumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::CumulativeGroupedAllocationConfig copied = new(model); + + Assert.Equal(model, copied); + } } public class CumulativeGroupedAllocationConversionRateConfigTest : TestBase @@ -9413,16 +10515,23 @@ public void TieredSerializationRoundtripWorks() } } -public class MinimumTest : TestBase +public class DailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9452,19 +10561,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::MinimumCadence.Annual; - string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() + ApiEnum expectedCadence = + Subscriptions::DailyCreditAllowanceCadence.Annual; + Subscriptions::DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9474,7 +10587,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9495,12 +10608,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(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); 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 +10628,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10643,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9562,12 +10684,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 +10701,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9612,26 +10742,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::MinimumCadence.Annual; - string expectedItemID = "item_id"; - Subscriptions::MinimumConfig expectedMinimumConfig = new() + ApiEnum expectedCadence = + Subscriptions::DailyCreditAllowanceCadence.Annual; + Subscriptions::DailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -9641,7 +10775,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::MinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::DailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9662,12 +10796,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(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); 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 +10819,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10834,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -9732,6 +10875,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9742,11 +10886,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9772,6 +10923,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10934,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", }; @@ -9795,11 +10955,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9813,6 +10980,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9839,6 +11007,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11018,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Minimum + var model = new Subscriptions::DailyCreditAllowance { - Cadence = Subscriptions::MinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", BillableMetricID = null, @@ -9866,57 +11043,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 MinimumCadenceTest : TestBase +public class DailyCreditAllowanceCadenceTest : TestBase { [Theory] - [InlineData(Subscriptions::MinimumCadence.Annual)] - [InlineData(Subscriptions::MinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::MinimumCadence.Monthly)] - [InlineData(Subscriptions::MinimumCadence.Quarterly)] - [InlineData(Subscriptions::MinimumCadence.OneTime)] - [InlineData(Subscriptions::MinimumCadence.Custom)] - public void Validation_Works(Subscriptions::MinimumCadence rawValue) + [InlineData(Subscriptions::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::MinimumCadence.Annual)] - [InlineData(Subscriptions::MinimumCadence.SemiAnnual)] - [InlineData(Subscriptions::MinimumCadence.Monthly)] - [InlineData(Subscriptions::MinimumCadence.Quarterly)] - [InlineData(Subscriptions::MinimumCadence.OneTime)] - [InlineData(Subscriptions::MinimumCadence.Custom)] - public void SerializationRoundtrip_Works(Subscriptions::MinimumCadence rawValue) + [InlineData(Subscriptions::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); @@ -9925,48 +11156,70 @@ 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 DailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + 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(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + 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::MinimumConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + 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 ); @@ -9977,131 +11230,223 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + 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 expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + 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(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + 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::MinimumConfig + var model = new Subscriptions::DailyCreditAllowanceConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } + var model = new Subscriptions::DailyCreditAllowanceConfig + { + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + }; - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::MinimumConfig { MinimumAmount = "minimum_amount" }; + Subscriptions::DailyCreditAllowanceConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class MatrixValueTest : TestBase +{ [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::MatrixValue { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); + 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 OptionalNonNullablePropertiesSetToNullValidation_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::MinimumConfig + var model = new Subscriptions::MatrixValue { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + DimensionValues = ["string"], + 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() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + var model = new Subscriptions::MatrixValue { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DimensionValues = ["string"], + UnitAmount = "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, - }, - ] - ), + 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::MatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; - value.Validate(); + + model.Validate(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::MinimumConversionRateConfig value = new SharedUnitConversionRateConfig() + var model = new Subscriptions::MatrixValue { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; + + Subscriptions::MatrixValue copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class DailyCreditAllowanceConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + 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( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::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); } @@ -10109,41 +11454,51 @@ 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::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 PercentTest : TestBase +public class MeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10172,16 +11527,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::PercentCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + 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"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10190,7 +11554,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10211,14 +11575,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, model.MeteredAllowanceConfig); 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 +11595,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11610,20 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10278,12 +11652,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 +11669,20 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10328,23 +11711,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::PercentCadence.Annual; + ApiEnum expectedCadence = + Subscriptions::MeteredAllowanceCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + 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"; - Subscriptions::PercentConfig expectedPercentConfig = new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10353,7 +11745,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::MeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10374,14 +11766,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); + Assert.Equal(expectedMeteredAllowanceConfig, deserialized.MeteredAllowanceConfig); 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 +11789,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11804,20 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10444,6 +11846,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10454,12 +11857,20 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10484,6 +11895,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11906,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), }; model.Validate(); @@ -10507,12 +11928,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10525,6 +11954,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10551,6 +11981,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +11992,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::Percent + var model = new Subscriptions::MeteredAllowance { - Cadence = Subscriptions::PercentCadence.Annual, + 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", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10578,57 +12018,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::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", + }; + + Subscriptions::MeteredAllowance copied = new(model); + + Assert.Equal(model, copied); + } } -public class PercentCadenceTest : TestBase +public class MeteredAllowanceCadenceTest : 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::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; + 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::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; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -10637,38 +12132,63 @@ 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 MeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; - double expectedPercent = 0; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedPercent, model.Percent); + 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::PercentConfig { Percent = 0 }; + 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 ); @@ -10679,75 +12199,193 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::PercentConfig { Percent = 0 }; + var model = new Subscriptions::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); - double expectedPercent = 0; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedPercent, deserialized.Percent); + 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::PercentConfig { Percent = 0 }; + var model = new Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::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 Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + { + var model = new Subscriptions::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 Subscriptions::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 Subscriptions::MeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }; + + Subscriptions::MeteredAllowanceConfig copied = new(model); + + Assert.Equal(model, copied); + } } -public class PercentConversionRateConfigTest : TestBase +public class MeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; + Subscriptions::MeteredAllowanceConversionRateConfig 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::MeteredAllowanceConversionRateConfig 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::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); } @@ -10755,46 +12393,43 @@ 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::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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class EventOutputTest : TestBase +public class PercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10823,21 +12458,17 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - ApiEnum expectedCadence = - Subscriptions::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + 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() @@ -10846,7 +12477,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10867,14 +12498,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10886,6 +12518,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,17 +12533,12 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10939,12 +12567,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,17 +12584,12 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10994,28 +12618,24 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum expectedCadence = - Subscriptions::EventOutputCadence.Annual; - Subscriptions::EventOutputConfig expectedEventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + ApiEnum expectedCadence = + Subscriptions::PercentCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); + 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() @@ -11024,7 +12644,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::EventOutputConversionRateConfig expectedConversionRateConfig = + Subscriptions::PercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -11045,14 +12665,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -11067,6 +12688,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,17 +12703,12 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -11120,6 +12737,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -11130,17 +12748,12 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -11165,6 +12778,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,17 +12789,12 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -11193,17 +12803,12 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11216,6 +12821,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -11242,6 +12848,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,17 +12859,12 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::EventOutput + var model = new Subscriptions::Percent { - Cadence = Subscriptions::EventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + Cadence = Subscriptions::PercentCadence.Annual, ItemID = "item_id", Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -11274,34 +12877,82 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::Percent + { + Cadence = Subscriptions::PercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::Percent copied = new(model); + + Assert.Equal(model, copied); + } } -public class EventOutputCadenceTest : TestBase +public class PercentCadenceTest : 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::PercentCadence.Annual)] + [InlineData(Subscriptions::PercentCadence.SemiAnnual)] + [InlineData(Subscriptions::PercentCadence.Monthly)] + [InlineData(Subscriptions::PercentCadence.Quarterly)] + [InlineData(Subscriptions::PercentCadence.OneTime)] + [InlineData(Subscriptions::PercentCadence.Custom)] + public void Validation_Works(Subscriptions::PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; value.Validate(); } [Fact] public void InvalidEnumValidationThrows_Works() { - var value = JsonSerializer.Deserialize>( + var value = JsonSerializer.Deserialize>( JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions ); @@ -11311,20 +12962,20 @@ public void InvalidEnumValidationThrows_Works() } [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::PercentCadence.Annual)] + [InlineData(Subscriptions::PercentCadence.SemiAnnual)] + [InlineData(Subscriptions::PercentCadence.Monthly)] + [InlineData(Subscriptions::PercentCadence.Quarterly)] + [InlineData(Subscriptions::PercentCadence.OneTime)] + [InlineData(Subscriptions::PercentCadence.Custom)] + public void SerializationRoundtrip_Works(Subscriptions::PercentCadence rawValue) { // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; + ApiEnum value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< - ApiEnum + ApiEnum >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); @@ -11333,52 +12984,38 @@ public void SerializationRoundtrip_Works(Subscriptions::EventOutputCadence rawVa [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 EventOutputConfigTest : TestBase +public class PercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + double expectedPercent = 0; - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11389,313 +13026,286 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + double expectedPercent = 0; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { - var model = new Subscriptions::EventOutputConfig - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + var model = new Subscriptions::PercentConfig { Percent = 0 }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; - - Assert.Null(model.DefaultUnitRate); - Assert.False(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.False(model.RawData.ContainsKey("grouping_key")); - } + var model = new Subscriptions::PercentConfig { Percent = 0 }; - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::EventOutputConfig { UnitRatingKey = "x" }; + Subscriptions::PercentConfig copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class PercentConversionRateConfigTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void UnitValidationWorks() { - var model = new Subscriptions::EventOutputConfig + Subscriptions::PercentConversionRateConfig value = new SharedUnitConversionRateConfig() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("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")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void TieredValidationWorks() { - var model = new Subscriptions::EventOutputConfig + Subscriptions::PercentConversionRateConfig value = new SharedTieredConversionRateConfig() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, - }; - - model.Validate(); - } -} - -public class EventOutputConversionRateConfigTest : TestBase -{ - [Fact] - public void UnitValidationWorks() - { - Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), }; 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() + Subscriptions::PercentConversionRateConfig 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"), + var deserialized = JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); Assert.Equal(value, deserialized); } -} - -public class RemoveAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, model.AdjustmentID); - } - - [Fact] - public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); - } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void TieredSerializationRoundtripWorks() { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + 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.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - } - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::RemoveAdjustment { AdjustmentID = "h74gfhdjvn7ujokd" }; - - model.Validate(); + Assert.Equal(value, deserialized); } } -public class RemovePriceTest : TestBase +public class EventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::RemovePrice + 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", - 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 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 + 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, 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 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", - 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 json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11706,33 +13316,177 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::RemovePrice + 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", - 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::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"; - 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(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(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::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", - 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 +13495,64 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::RemovePrice { }; + var model = new Subscriptions::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.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::EventOutput + { + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, + ItemID = "item_id", + Name = "Annual fee", + }; model.Validate(); } @@ -11760,556 +13560,3192 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::RemovePrice { ExternalPriceID = null, PriceID = null }; + 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.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.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::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::EventOutput { - Adjustment = new NewPercentageDiscount() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ReplacesAdjustmentID = "replaces_adjustment_id", - }; + ItemID = "item_id", + Name = "Annual fee", - 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, + BillableMetricID = null, + BilledInAdvance = null, + 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::EventOutput { - Adjustment = new NewPercentageDiscount() + Cadence = Subscriptions::EventOutputCadence.Annual, + EventOutputConfig = 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, - ReplacesAdjustmentID = "replaces_adjustment_id", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 - ); + Subscriptions::EventOutput copied = new(model); - Assert.Equal(model, deserialized); + Assert.Equal(model, copied); } +} - [Fact] - public void FieldRoundtripThroughSerialization_Works() +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) { - 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", - }; + // 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, + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize>( + JsonSerializer.SerializeToElement("invalid value"), 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.NotNull(value); + Assert.Throws(() => value.Validate()); + } - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + [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 Validation_Works() + public void InvalidEnumSerializationRoundtrip_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", - }; + 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 ReplaceAdjustmentAdjustmentTest : TestBase +public class EventOutputConfigTest : TestBase { [Fact] - public void NewPercentageDiscountValidationWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] - public void NewUsageDiscountValidationWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewAmountDiscountValidationWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); } [Fact] - public void NewMinimumValidationWorks() + public void Validation_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - value.Validate(); + + model.Validate(); } [Fact] - public void NewMaximumValidationWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMaximum() + 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 { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMaximumFilterField.PriceID, - Operator = NewMaximumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMaximumPriceType.Usage, + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - value.Validate(); + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewPercentageDiscount() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewUsageDiscount() + var model = new Subscriptions::EventOutputConfig { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewUsageDiscountFilterField.PriceID, - Operator = NewUsageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewUsageDiscountPriceType.Usage, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::EventOutputConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class EventOutputConversionRateConfigTest : TestBase +{ [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewAmountDiscount() + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + value.Validate(); + } - Assert.Equal(value, deserialized); + [Fact] + public void TieredValidationWorks() + { + Subscriptions::EventOutputConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplaceAdjustmentAdjustment value = new NewMinimum() + Subscriptions::EventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, - ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewMinimumFilterField.PriceID, - Operator = NewMinimumFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewMinimumPriceType.Usage, + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - 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::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 - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } } -public class ReplacePriceTest : TestBase +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 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 FieldRoundtrip_Works() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + 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 = 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"), }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionGroupedTieredPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.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::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12338,58 +16774,164 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; + }; + value.Validate(); + } - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + [Fact] + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + 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", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() + 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() { - 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::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::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -12418,77 +16960,37 @@ public void FieldRoundtrip_Works() 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.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - 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::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", }, - ], - 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::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12517,71 +17019,29 @@ 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); - var deserialized = JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CumulativeGroupedAllocationValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() { - 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::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + 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, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12610,65 +17070,86 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + }; + value.Validate(); + } - string expectedReplacesPriceID = "replaces_price_id"; - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + Subscriptions::ReplacePricePrice value = + new Subscriptions::ReplacePricePriceDailyCreditAllowance() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 2; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - Subscriptions::ReplacePricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + MeteredAllowanceConfig = new() + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", + }, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12697,77 +17178,29 @@ public void FieldRoundtripThroughSerialization_Works() 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.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionMinimumCompositeValidationWorks() { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - 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::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + MinimumCompositeConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + MinimumAmount = "minimum_amount", + Prorated = 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, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12796,170 +17229,22 @@ 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::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - - Assert.Null(model.AllocationPrice); - Assert.False(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.False(model.RawData.ContainsKey("discounts")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.False(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.False(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.False(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::ReplacePrice { ReplacesPriceID = "replaces_price_id" }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; - - Assert.Null(model.AllocationPrice); - Assert.True(model.RawData.ContainsKey("allocation_price")); - Assert.Null(model.Discounts); - Assert.True(model.RawData.ContainsKey("discounts")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.MaximumAmount); - Assert.True(model.RawData.ContainsKey("maximum_amount")); - Assert.Null(model.MinimumAmount); - Assert.True(model.RawData.ContainsKey("minimum_amount")); - Assert.Null(model.Price); - Assert.True(model.RawData.ContainsKey("price")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::ReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; - - model.Validate(); - } -} - -public class ReplacePricePriceTest : TestBase -{ - [Fact] - public void NewSubscriptionUnitValidationWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + }; value.Validate(); } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void PercentValidationWorks() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() + Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePricePercent() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - TieredConfig = new() - { - Tiers = - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ], - Prorated = true, - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12988,6 +17273,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -12995,14 +17281,18 @@ public void NewSubscriptionTieredValidationWorks() } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void EventOutputValidationWorks() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionBulkPrice() + Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceEventOutput() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceEventOutputCadence.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,6 +17322,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13039,67 +17330,15 @@ public void NewSubscriptionBulkValidationWorks() } [Fact] - public void BulkWithFiltersValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() - { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionPackageValidationWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionPackagePrice() + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.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() @@ -13128,27 +17367,41 @@ 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 NewSubscriptionTieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], + Tiers = + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ], + Prorated = true, }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13177,202 +17430,87 @@ 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 + ); - [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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + 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() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() - { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = 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::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(); + 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 NewSubscriptionGroupedTieredValidationWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::ReplacePricePriceBulkWithFilters() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + BulkWithFiltersConfig = new() { - GroupingKey = "x", + 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" }, ], }, + Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13402,194 +17540,146 @@ 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 NewSubscriptionPackageSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + 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() { - 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(); + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewSubscriptionPackageWithAllocationValidationWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionMatrixPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + ItemID = "item_id", + MatrixConfig = new() { - 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(); + 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 NewSubscriptionUnitWithPercentValidationWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() - { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() - { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + ThresholdTotalAmountConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + ConsumptionTable = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, ], + Prorate = true, }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13618,24 +17708,38 @@ 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 NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceTieredWithProration() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), + TieredPackageConfig = new() + { + PackageSize = "package_size", + Tiers = + [ + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + ], + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13664,24 +17768,50 @@ 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 NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13710,28 +17840,37 @@ 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 NewSubscriptionGroupedTieredSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { - Allocation = "allocation", GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13761,29 +17900,49 @@ 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 NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -13812,30 +17971,36 @@ 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 NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13864,43 +18029,31 @@ 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 + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() - { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = - [ - new() - { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, - ], - }, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13929,27 +18082,39 @@ 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); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, - ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13979,36 +18144,31 @@ public void GroupedWithMinMaxThresholdsValidationWorks() 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void TieredWithProrationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::ReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.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() @@ -14037,33 +18197,31 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() 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 NewSubscriptionGroupedTieredPackageValidationWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - 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::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, Name = "Annual fee", + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14092,32 +18250,35 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, - ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { + Allocation = "allocation", GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + OverageUnitRate = "overage_unit_rate", }, + ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14147,40 +18308,36 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() 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 NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.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::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, 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() @@ -14209,43 +18366,37 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() 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 NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, 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() @@ -14274,35 +18425,49 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() 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 NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - DimensionValues = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ new() { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", }, ], - Group = "group", + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + ], }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14332,25 +18497,32 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() 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 CumulativeGroupedAllocationValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, ItemID = "item_id", Name = "Annual fee", @@ -14382,70 +18554,42 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceMinimum() - { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() + MatrixWithDisplayNameConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], }, ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14466,153 +18610,19 @@ public void NewSubscriptionMinimumCompositeValidationWorks() DimensionValues = ["string"], DimensionalPriceGroupID = "dimensional_price_group_id", ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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 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, - }, - 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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - value.Validate(); - } - - [Fact] - public void NewSubscriptionUnitSerializationRoundtripWorks() - { - Subscriptions::ReplacePricePrice value = new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, - Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + }, + ExternalPriceID = "external_price_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, @@ -14623,58 +18633,58 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { - 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() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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, @@ -14685,46 +18695,128 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { - 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() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - 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::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() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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, @@ -14735,23 +18827,36 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Name = "Annual fee", + ScalableMatrixWithTieredPricingConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + FirstDimension = "first_dimension", + MatrixScalingFactors = + [ + new() + { + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", + }, + ], Tiers = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], + SecondDimension = "second_dimension", }, - Cadence = Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14780,6 +18885,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14793,101 +18899,61 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [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, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - 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() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { - 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() + Subscriptions::ReplacePricePrice value = + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + 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, @@ -14898,25 +18964,21 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, + 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() @@ -14945,6 +19007,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14958,24 +19021,25 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::ReplacePricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - PackageSize = "package_size", - Tiers = + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { 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() @@ -15004,6 +19068,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15016,37 +19081,24 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() 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, + [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() @@ -15075,6 +19127,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15088,23 +19141,20 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + MinimumAmount = "minimum_amount", + Prorated = true, }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15134,6 +19184,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15147,1321 +19198,1245 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + 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() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = 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 = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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 - ); + 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", + }; - 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 NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - 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", + 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" }, + ], }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + 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); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = 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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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", + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() - { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceTieredWithProration() + 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() { - Cadence = Subscriptions::ReplacePricePriceTieredWithProrationCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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.Equal(value, deserialized); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + 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() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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 - ); + 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.Equal(value, deserialized); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + var model = new Subscriptions::ReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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", + }; - Assert.Equal(value, deserialized); + Subscriptions::ReplacePricePriceBulkWithFilters copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTest : TestBase +{ [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void FieldRoundtrip_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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.Equal(value, deserialized); + 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 NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void SerializationRoundtrip_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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.Equal(value, deserialized); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; + + 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(value, deserialized); + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void Validation_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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + 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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + { + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = + [ + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + ], + }; - Assert.Equal(value, deserialized); + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig copied = new(model); + + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest : TestBase +{ [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() - { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, model.PropertyKey); + Assert.Equal(expectedPropertyValue, model.PropertyValue); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); + } - Assert.Equal(value, deserialized); + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void CopyConstructor_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", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = new( + model ); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } +} +public class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest : TestBase +{ [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() - { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, - Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - UnitPrice = "unit_price", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; - Assert.Equal(value, deserialized); + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); } [Fact] - public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() - { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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); + } - Assert.Equal(value, deserialized); + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() - { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); } [Fact] - public void CumulativeGroupedAllocationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::ReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void MinimumSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - Subscriptions::ReplacePricePrice value = new Subscriptions::ReplacePricePriceMinimum() + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - Cadence = Subscriptions::ReplacePricePriceMinimumCadence.Annual, - ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + UnitAmount = "unit_amount", + + TierLowerBound = null, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = new( + model ); + Assert.Equal(model, copied); + } +} + +public class ReplacePricePriceBulkWithFiltersCadenceTest : TestBase +{ + [Theory] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void Validation_Works(Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + + [Fact] + public void InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Annual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.SemiAnnual)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Monthly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Quarterly)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.OneTime)] + [InlineData(Subscriptions::ReplacePricePriceBulkWithFiltersCadence.Custom)] + public void SerializationRoundtrip_Works( + Subscriptions::ReplacePricePriceBulkWithFiltersCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid 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 NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::ReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig 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"), }; - 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() { - 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() + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); Assert.Equal(value, deserialized); } [Fact] - public void 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::ReplacePricePriceBulkWithFiltersConversionRateConfig 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 +20465,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 +20487,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16538,14 +20508,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 +20528,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +20543,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 +20579,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 +20597,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 +20633,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 +20663,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16728,14 +20684,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 +20707,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +20722,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 +20758,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -16816,20 +20769,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 +20801,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +20812,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 +20828,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 +20848,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -16936,274 +20874,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 +21075,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 +21238,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17400,7 +21259,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17408,7 +21267,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17419,7 +21278,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17436,7 +21295,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17445,19 +21304,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 +21349,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 +21380,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17528,14 +21401,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 +21424,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +21439,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 +21479,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 +21497,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 +21537,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 +21552,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 +21576,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17700,14 +21597,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 +21623,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +21638,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 +21678,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17782,14 +21689,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 +21725,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +21736,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 +21756,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 +21780,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17885,6 +21807,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +21818,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 +21842,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 +21927,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 +21935,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 +21961,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 +22024,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 +22102,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18186,7 +22123,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18194,7 +22131,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18205,7 +22142,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18222,7 +22159,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18231,20 +22168,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 +22213,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 +22244,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18327,13 +22265,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 +22288,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +22303,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 +22343,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 +22361,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 +22401,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 +22416,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 +22440,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18519,13 +22461,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 +22487,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22502,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 +22542,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18608,15 +22553,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 +22589,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22600,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 +22620,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 +22644,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18723,6 +22671,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22682,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 +22791,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 +22799,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 +22825,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 +22888,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 +22966,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18965,7 +22987,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18973,7 +22995,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18984,7 +23006,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19001,7 +23023,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19010,20 +23032,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 +23078,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 +23107,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19106,14 +23128,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 +23148,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +23163,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 +23204,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 +23222,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 +23263,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 +23278,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 +23300,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19298,14 +23321,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 +23344,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +23359,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 +23400,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19387,15 +23411,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 +23448,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23459,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 +23480,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 +23505,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19502,6 +23532,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23543,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 +23568,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 +23654,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 +23662,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 +23688,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 +23871,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 +23891,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 +23920,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 +23963,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19744,7 +23984,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19752,7 +23992,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19763,7 +24003,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::ReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19780,7 +24020,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19789,16 +24029,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 +24076,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 +24104,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19871,12 +24125,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 +24145,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +24160,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 +24202,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 +24220,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 +24262,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 +24298,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::ReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20038,12 +24319,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 +24342,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +24357,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 +24399,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20118,11 +24410,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 +24448,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24459,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 +24481,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 +24507,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20215,6 +24534,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24545,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 +24571,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 +24655,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 +24663,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 +24688,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 +24755,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 +24807,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 +24838,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 +24910,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20478,7 +24931,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20486,7 +24939,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20497,7 +24950,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::ReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::ReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20514,7 +24967,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20562,6 +25015,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20601,6 +25055,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 +25075,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25124,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20718,6 +25175,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20764,6 +25222,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 +25245,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25294,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -20874,6 +25335,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25378,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20941,6 +25405,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25434,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 +25606,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 +25745,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21266,6 +25791,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 +25811,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25865,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21393,6 +25921,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21445,6 +25974,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 +25997,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26051,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21565,6 +26097,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26150,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21642,6 +26177,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26211,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 +26472,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..c42bdeb84 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,6 +2947,7 @@ public void NewFloatingMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2563,6 +2993,7 @@ public void NewFloatingTieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2606,6 +3037,7 @@ public void NewFloatingUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2654,6 +3086,7 @@ public void NewFloatingGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2702,6 +3135,7 @@ public void NewFloatingBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2751,6 +3185,7 @@ public void NewFloatingGroupedWithProratedMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2809,6 +3244,7 @@ public void NewFloatingGroupedWithMeteredMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2857,6 +3293,7 @@ public void GroupedWithMinMaxThresholdsValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2912,6 +3349,7 @@ public void NewFloatingMatrixWithDisplayNameValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -2964,6 +3402,7 @@ public void NewFloatingGroupedTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3016,6 +3455,7 @@ public void NewFloatingMaxGroupTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3045,6 +3485,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -3075,6 +3516,7 @@ public void NewFloatingScalableMatrixWithUnitPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3137,6 +3579,7 @@ public void NewFloatingScalableMatrixWithTieredPricingValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3192,6 +3635,7 @@ public void NewFloatingCumulativeGroupedBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3240,20 +3684,79 @@ public void CumulativeGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + value.Validate(); + } + + [Fact] + public void DailyCreditAllowanceValidationWorks() + { + 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" } }, }; value.Validate(); } [Fact] - public void MinimumValidationWorks() + public void MeteredAllowanceValidationWorks() { - 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, @@ -3282,6 +3785,7 @@ public void MinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3325,6 +3829,7 @@ public void NewFloatingMinimumCompositeValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3367,6 +3872,7 @@ public void PercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3414,6 +3920,7 @@ public void EventOutputValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; value.Validate(); @@ -3457,6 +3964,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 +4026,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 +4076,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 +4133,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 +4183,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 +4238,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 +4296,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 +4354,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 +4423,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 +4481,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 +4549,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 +4604,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 +4654,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 +4710,7 @@ public void NewFloatingMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -4241,6 +4762,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 +4812,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 +4867,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 +4922,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 +4978,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 +5043,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 +5098,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 +5160,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 +5219,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 +5278,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 +5314,7 @@ public void NewFloatingScalableMatrixWithUnitPricingSerializationRoundtripWorks( }, ], UnitPrice = "unit_price", + GroupingKey = "x", Prorate = true, SecondDimension = "second_dimension", }, @@ -4813,6 +5345,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 +5414,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 +5476,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 +5531,7 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5008,14 +5544,21 @@ public void CumulativeGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void MinimumSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { - 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, @@ -5044,6 +5587,7 @@ public void MinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5056,15 +5600,22 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewFloatingMinimumCompositeSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { - 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, @@ -5093,6 +5644,7 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); @@ -5105,15 +5657,16 @@ public void NewFloatingMinimumCompositeSerializationRoundtripWorks() } [Fact] - public void PercentSerializationRoundtripWorks() + public void NewFloatingMinimumCompositeSerializationRoundtripWorks() { - 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() @@ -5141,6 +5694,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); @@ -5153,20 +5707,15 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { - 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() @@ -5194,6 +5743,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); @@ -5204,14 +5754,68 @@ public void EventOutputSerializationRoundtripWorks() Assert.Equal(value, deserialized); } -} -public class PriceModelBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void EventOutputSerializationRoundtripWorks() { - var model = new Subscriptions::PriceModelBulkWithFilters + 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" } }, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PriceModelBulkWithFiltersTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::PriceModelBulkWithFilters { BulkWithFiltersConfig = new() { @@ -5253,6 +5857,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5300,6 +5905,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 +5924,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +5980,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5430,6 +6038,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5484,6 +6093,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 +6115,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +6171,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -5606,6 +6218,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +6276,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -5685,6 +6300,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +6335,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 +6515,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 +6607,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 +6745,20 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::PriceModelBulkWithFiltersBulkWithFiltersConfigTier copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelBulkWithFiltersCadenceTest : TestBase @@ -6235,6 +6953,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6284,6 +7003,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -6305,6 +7025,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -6358,6 +7079,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6414,6 +7136,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6471,6 +7194,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -6495,6 +7219,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -6548,6 +7273,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -6592,6 +7318,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -6644,6 +7372,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -6667,6 +7396,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -6698,11 +7429,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelGroupedWithMinMaxThresholds + { + Cadence = Subscriptions::PriceModelGroupedWithMinMaxThresholdsCadence.Annual, + Currency = "currency", + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelGroupedWithMinMaxThresholds copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelGroupedWithMinMaxThresholdsCadenceTest : TestBase @@ -6865,6 +7649,24 @@ public void Validation_Works() model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + Subscriptions::PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig copied = + new(model); + + Assert.Equal(model, copied); + } } public class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigTest : TestBase @@ -6995,6 +7797,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7044,6 +7847,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, model.Cadence); @@ -7065,6 +7869,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -7118,6 +7923,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7174,6 +7980,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7231,6 +8038,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; Assert.Equal(expectedCadence, deserialized.Cadence); @@ -7255,6 +8063,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -7308,6 +8117,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -7352,6 +8162,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); } @@ -7404,6 +8216,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -7427,6 +8240,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); } @@ -7458,11 +8273,64 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::PriceModelCumulativeGroupedAllocation + { + Cadence = Subscriptions::PriceModelCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + Currency = "currency", + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + }; + + Subscriptions::PriceModelCumulativeGroupedAllocation copied = new(model); + + Assert.Equal(model, copied); + } } public class PriceModelCumulativeGroupedAllocationCadenceTest : TestBase @@ -7625,14 +8493,996 @@ public void Validation_Works() model.Validate(); } -} -public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; + + Subscriptions::PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class PriceModelCumulativeGroupedAllocationConversionRateConfigTest : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } +} + +public class PriceModelDailyCreditAllowanceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_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" } }, + }; + + ApiEnum expectedCadence = + Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig 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; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig 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(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(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); + Assert.NotNull(model.Metadata); + Assert.Equal(expectedMetadata.Count, model.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::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 json = 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::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(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + ApiEnum expectedCadence = + Subscriptions::PriceModelDailyCreditAllowanceCadence.Annual; + string expectedCurrency = "currency"; + Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig 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; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig 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(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( + expectedDimensionalPriceConfiguration, + deserialized.DimensionalPriceConfiguration + ); + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); + Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); + Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); + Assert.NotNull(deserialized.Metadata); + Assert.Equal(expectedMetadata.Count, deserialized.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::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" } }, + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_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", + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(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::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", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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 = 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::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 = 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::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 PriceModelDailyCreditAllowanceCadenceTest : TestBase +{ + [Theory] + [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; + value.Validate(); + } + + [Fact] + 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::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::PriceModelDailyCreditAllowanceCadence rawValue + ) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +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::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 Subscriptions::PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 PriceModelDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7644,7 +9494,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7665,7 +9515,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7673,7 +9523,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7684,7 +9534,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::PriceModelDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7701,7 +9551,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7710,17 +9560,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 +9607,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 +9635,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7791,12 +9655,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 +9674,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9688,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 +9730,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 +9746,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 +9788,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 +9823,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::PriceModelMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7954,12 +9843,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 +9865,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9879,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 +9921,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8031,12 +9931,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 +9968,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +9977,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 +10000,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 +10026,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8123,6 +10050,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +10059,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 +10085,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 +10167,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 +10175,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 +10200,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 +10267,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 +10319,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 +10350,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 +10422,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8381,7 +10443,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8389,7 +10451,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8400,7 +10462,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::PriceModelMinimumConversionRateConfig value = + Subscriptions::PriceModelMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8417,7 +10479,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8465,6 +10527,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8503,6 +10566,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 +10585,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +10633,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8617,6 +10683,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8662,6 +10729,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 +10751,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +10799,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -8768,6 +10838,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +10880,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -8831,6 +10904,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +10931,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 +11099,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 +11238,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9149,6 +11282,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 +11301,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +11354,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9273,6 +11409,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9323,6 +11460,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 +11482,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +11535,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, }; @@ -9439,6 +11579,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_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 +11631,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, }; @@ -9512,6 +11655,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_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 +11687,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 +11944,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 +12051,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 +12073,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 +12101,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 +12114,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 +12136,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 +12154,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 +12176,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 +12188,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 +12212,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 +12225,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 +12247,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 +12258,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 +12274,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 +12285,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 +12305,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 +12314,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 +12769,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 +12779,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 +12800,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 +12824,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 +12849,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 +12859,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 +12884,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 +12894,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 +12912,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 +12922,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 +12946,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 +12976,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 +12986,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 +13005,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 +13015,10 @@ public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10746,7 +13034,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 +13044,10 @@ public void OptionalNonNullablePropertiesUnsetValidation_Works() Quantity = 5, }, ], + MetricParameterOverrides = new Dictionary() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, + }, UsageCustomerIds = ["string"], }; @@ -10770,7 +13062,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 +13072,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 +13094,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 +13104,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 +13123,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 +13136,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 +13148,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 +13160,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 +13181,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 +13193,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 +13354,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 +13421,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 +13441,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 +13460,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 +13472,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 +13487,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 +13500,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 +13513,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 +13525,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 +13541,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 +13556,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 +13569,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 +13581,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 +13596,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..6e0929026 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,787 +804,2792 @@ 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"], + 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"), + }, + ], + AlignBillingWithPlanChangeDate = true, + AutoCollection = true, + BillingCycleAlignment = Subscriptions::BillingCycleAlignment.Unchanged, + BillingCycleAnchorConfiguration = new() + { + Day = 1, + Month = 1, + Year = 0, + }, + ChangeDate = DateTimeOffset.Parse("2017-07-21T17:32:28Z"), + CouponRedemptionCode = "coupon_redemption_code", + CreditsOverageRate = 0, + DefaultInvoiceMemo = "default_invoice_memo", + ExternalPlanID = "ZMwNQefe7J3ecf7W", + Filter = "my_property > 100 AND my_other_property = 'bar'", + InitialPhaseOrder = 2, + InvoicingThreshold = "10.00", + NetTerms = 0, + PerCreditOverageAmount = 0, + PlanID = "ZMwNQefe7J3ecf7W", + PlanVersionNumber = 0, + PriceOverrides = [JsonSerializer.Deserialize("{}")], + RemoveAdjustments = [new("h74gfhdjvn7ujokd")], + RemovePrices = + [ + new() { ExternalPriceID = "external_price_id", PriceID = "h74gfhdjvn7ujokd" }, + ], + ReplaceAdjustments = + [ + new() + { + Adjustment = new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }, + ], + ReplacePrices = + [ + new() + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, + Filters = + [ + new() + { + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, + Values = ["string"], + }, + ], + ItemID = "item_id", + 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"], + }; + + 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 = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + 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"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + 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", }, - EndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"), - PlanPhaseOrder = 0, + 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); + model.Validate(); + } - 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"); + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; - Assert.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedEndDate, deserialized.EndDate); - Assert.Equal(expectedPlanPhaseOrder, deserialized.PlanPhaseOrder); - Assert.Equal(expectedStartDate, deserialized.StartDate); + 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 Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice { - Adjustment = new NewPercentageDiscount() + 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() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + LicenseTypeID = "license_type_id", + 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(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void NewSubscriptionTieredValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.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 = 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")); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewSubscriptionBulkValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionBulkPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.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 = 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 BulkWithFiltersValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = 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 = + 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", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }, - - EndDate = null, - PlanPhaseOrder = null, - StartDate = null, - }; + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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.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 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 OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionMatrixValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustment - { - Adjustment = 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, - }, - - 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 NewSubscriptionThresholdTotalAmountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.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 = 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 NewSubscriptionTieredPackageValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackagePrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.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 = 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 NewSubscriptionTieredWithMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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 NewSubscriptionGroupedTieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + 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", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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 = 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 NewSubscriptionTieredPackageWithMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() + public void NewSubscriptionPackageWithAllocationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewPercentageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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 NewUsageDiscountSerializationRoundtripWorks() + public void NewSubscriptionUnitWithPercentValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewUsageDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, - UsageDiscount = 0, - AppliesToAll = NewUsageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewAmountDiscount() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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); + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void TieredWithProrationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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", - 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, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionGroupedAllocationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() - { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], - }, - ], ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, - ], - 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() + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.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::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1585,59 +3618,31 @@ 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"), - }; + }; + value.Validate(); + } - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + [Fact] + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", }, - ], - ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1666,79 +3671,96 @@ 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"); + value.Validate(); + } - Assert.Equal(expectedAllocationPrice, model.AllocationPrice); - Assert.NotNull(model.Discounts); - Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); - for (int i = 0; i < expectedDiscounts.Count; i++) - { - Assert.Equal(expectedDiscounts[i], model.Discounts[i]); - } - Assert.Equal(expectedEndDate, model.EndDate); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedMaximumAmount, model.MaximumAmount); - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPlanPhaseOrder, model.PlanPhaseOrder); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); - Assert.Equal(expectedStartDate, model.StartDate); + [Fact] + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + { + 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 SerializationRoundtrip_Works() + public void GroupedWithMinMaxThresholdsValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_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, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1767,73 +3789,37 @@ 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); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionMatrixWithDisplayNameValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - 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::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + MatrixWithDisplayNameConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + 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::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1862,67 +3848,34 @@ 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); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + }; + value.Validate(); + } - NewAllocationPrice expectedAllocationPrice = new() - { - Amount = "10.00", - Cadence = Cadence.Monthly, - Currency = "USD", - CustomExpiration = new() + [Fact] + public void NewSubscriptionGroupedTieredPackageValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Duration = 0, - DurationUnit = CustomExpirationDurationUnit.Day, - }, - ExpiresAtEndOfCadence = true, - Filters = - [ - new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - Field = NewAllocationPriceFilterField.ItemID, - Operator = NewAllocationPriceFilterOperator.Includes, - Values = ["string"], + 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", - PerUnitCostBasis = "per_unit_cost_basis", - }; - List expectedDiscounts = - [ - new() - { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, - }, - ]; - DateTimeOffset expectedEndDate = DateTimeOffset.Parse("2019-12-27T18:11:19.117Z"); - string expectedExternalPriceID = "external_price_id"; - string expectedMaximumAmount = "1.23"; - string expectedMinimumAmount = "1.23"; - long expectedPlanPhaseOrder = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice expectedPrice = - new Subscriptions::NewSubscriptionUnitPrice() - { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -1951,79 +3904,34 @@ 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"); - - 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); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { - 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"], - }, - ], + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - PerUnitCostBasis = "per_unit_cost_basis", - }, - Discounts = - [ - new() + MaxGroupTieredPackageConfig = new() { - DiscountType = Subscriptions::DiscountType.Percentage, - AmountDiscount = "amount_discount", - PercentageDiscount = 0.15, - UsageDiscount = 0, + GroupingKey = "x", + PackageSize = "package_size", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", 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::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2052,124 +3960,42 @@ public void Validation_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"), - }; - - 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")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPrice - { - AllocationPrice = null, - Discounts = null, - EndDate = null, - ExternalPriceID = null, - MaximumAmount = null, - MinimumAmount = null, - PlanPhaseOrder = null, - Price = null, - PriceID = null, - StartDate = null, - }; - - model.Validate(); + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -2198,6 +4024,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2205,27 +4032,35 @@ public void NewSubscriptionUnitValidationWorks() } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, Name = "Annual fee", - TieredConfig = new() + ScalableMatrixWithTieredPricingConfig = new() { - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - Prorated = true, + 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, @@ -2255,6 +4090,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2262,15 +4098,28 @@ public void NewSubscriptionTieredValidationWorks() } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2300,6 +4149,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2307,22 +4157,20 @@ public void NewSubscriptionBulkValidationWorks() } [Fact] - public void BulkWithFiltersValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - BulkWithFiltersConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", @@ -2353,6 +4201,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2360,16 +4209,26 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void DailyCreditAllowanceValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + 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", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2398,6 +4257,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2405,23 +4265,23 @@ public void NewSubscriptionPackageValidationWorks() } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void MeteredAllowanceValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - MatrixConfig = new() + MeteredAllowanceConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = - [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, - ], + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2451,6 +4311,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2458,25 +4319,21 @@ public void NewSubscriptionMatrixValidationWorks() } [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MinimumCompositeConfig = new() { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, + MinimumAmount = "minimum_amount", + Prorated = true, }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2505,6 +4362,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2512,24 +4370,16 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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" }, - ], - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2558,6 +4408,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2565,36 +4416,21 @@ public void NewSubscriptionTieredPackageValidationWorks() } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = 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, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2623,6 +4459,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -2630,24 +4467,16 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - 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" }, - ], - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2676,41 +4505,42 @@ 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 NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + TieredConfig = 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", + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, }, ], + Prorated = true, }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -2740,29 +4570,31 @@ 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 NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), + Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + ModelType = Subscriptions::ModelType.Bulk, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2791,24 +4623,39 @@ 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 BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.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::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2837,33 +4684,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 NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::NewSubscriptionPackagePrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.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, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2892,25 +4737,39 @@ 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 NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", + MatrixConfig = new() + { + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2939,24 +4798,40 @@ 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 NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), + ThresholdTotalAmountConfig = new() + { + ConsumptionTable = + [ + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + new() { Threshold = "threshold", TotalAmount = "total_amount" }, + ], + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -2985,29 +4860,39 @@ 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 NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + 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() @@ -3036,29 +4921,51 @@ 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 NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, + 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() @@ -3087,29 +4994,38 @@ 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 NewSubscriptionGroupedTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, + GroupedTieredConfig = new() { GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + Tiers = + [ + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3139,43 +5055,50 @@ 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 + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Name = "Annual fee", + TieredPackageWithMinimumConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + PackageSize = 0, + Tiers = [ new() { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", + }, + new() + { + MinimumAmount = "minimum_amount", + PerUnit = "per_unit", + TierLowerBound = "tier_lower_bound", }, - ], - 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() @@ -3204,29 +5127,37 @@ 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); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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() @@ -3255,36 +5186,32 @@ public void GroupedWithMinMaxThresholdsValidationWorks() 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", - MatrixWithDisplayNameConfig = new() - { - Dimension = "dimension", - UnitAmounts = - [ - new() - { - DimensionValue = "dimension_value", - DisplayName = "display_name", - UnitAmount = "unit_amount", - }, - ], - }, ModelType = - Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3313,32 +5240,40 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() 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 NewSubscriptionGroupedTieredPackageValidationWorks() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, - GroupedTieredPackageConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3368,33 +5303,33 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void TieredWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() - { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3423,40 +5358,32 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() 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 NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, 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", - }, + UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3485,43 +5412,37 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() 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 NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, 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() @@ -3550,35 +5471,36 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() 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 NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = + BulkWithProrationConfig = new( [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, + 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::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3608,28 +5530,37 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() 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 CumulativeGroupedAllocationValidationWorks() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", GroupingKey = "x", - UnitAmount = "unit_amount", + Minimum = "minimum", + UnitRate = "unit_rate", }, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3659,22 +5590,50 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + 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", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3704,27 +5663,36 @@ public void MinimumValidationWorks() 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 NewSubscriptionMinimumCompositeValidationWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() { - MinimumAmount = "minimum_amount", - Prorated = true, + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3754,23 +5722,44 @@ public void NewSubscriptionMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + Dimension = "dimension", + UnitAmounts = + [ + new() + { + DimensionValue = "dimension_value", + DisplayName = "display_name", + UnitAmount = "unit_amount", + }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3799,27 +5788,40 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + 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, @@ -3849,23 +5851,41 @@ public void EventOutputValidationWorks() 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 NewSubscriptionUnitSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + 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", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -3894,6 +5914,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3908,27 +5929,33 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - TieredConfig = new() + ScalableMatrixWithUnitPricingConfig = new() { - Tiers = + FirstDimension = "first_dimension", + MatrixScalingFactors = [ new() { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, + FirstDimensionValue = "first_dimension_value", + ScalingFactor = "scaling_factor", + SecondDimensionValue = "second_dimension_value", }, ], - Prorated = true, + UnitPrice = "unit_price", + GroupingKey = "x", + Prorate = true, + SecondDimension = "second_dimension", }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -3958,6 +5985,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -3972,16 +6000,36 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + 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() @@ -4010,6 +6058,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4024,23 +6073,28 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - BulkWithFiltersConfig = new() + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + DimensionValues = [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, ], + Group = "group", }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4070,6 +6124,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4084,16 +6139,22 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, 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() @@ -4122,6 +6183,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4136,23 +6198,25 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { + DailyAllowance = "daily_allowance", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], + EventDayProperty = "x", MatrixValues = [ new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4182,6 +6246,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4196,25 +6261,24 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + MeteredAllowanceConfig = new() { - ConsumptionTable = - [ - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - new() { Threshold = "threshold", TotalAmount = "total_amount" }, - ], - Prorate = true, + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4243,6 +6307,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4257,24 +6322,21 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + MinimumCompositeConfig = new() { - PackageSize = "package_size", - Tiers = - [ - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - new() { PerUnit = "per_unit", TierLowerBound = "tier_lower_bound" }, - ], + MinimumAmount = "minimum_amount", + Prorated = true, }, + ModelType = + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4303,6 +6365,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4317,36 +6380,16 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.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, - }, + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4375,6 +6418,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4389,23 +6433,20 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4435,6 +6476,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -4447,37 +6489,29 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, - Name = "Annual fee", - TieredPackageWithMinimumConfig = new() + BulkWithFiltersConfig = new() { - PackageSize = 0, + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], Tiers = [ - new() - { - MinimumAmount = "minimum_amount", - PerUnit = "per_unit", - TierLowerBound = "tier_lower_bound", - }, - new() - { - MinimumAmount = "minimum_amount", - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4506,36 +6540,109 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + 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 NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, - Name = "Annual fee", - PackageWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", + 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() @@ -4564,31 +6671,40 @@ 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 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 NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.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::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -4617,39 +6733,119 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + 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 + > 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); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + BulkWithFiltersConfig = new() { - Allocation = "allocation", - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], + Tiers = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, + new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, ], }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -4679,142 +6875,212 @@ 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::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", Name = "Annual fee", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_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); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters { - 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() + 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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void CopyConstructor_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, @@ -4844,764 +7110,563 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + 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( - element, + JsonSerializer.Deserialize( + json, ModelBase.SerializerOptions ); - Assert.Equal(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig { - 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", + 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(value, ModelBase.SerializerOptions); + + 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" }, + ]; + + 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(value, deserialized); + Assert.Equal(model, deserialized); } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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", + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); + Assert.NotNull(deserialized); - Assert.Equal(value, deserialized); + string expectedPropertyKey = "x"; + string expectedPropertyValue = "x"; + + Assert.Equal(expectedPropertyKey, deserialized.PropertyKey); + Assert.Equal(expectedPropertyValue, deserialized.PropertyValue); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void Validation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - 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", + PropertyKey = "x", + PropertyValue = "x", }; - 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 CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PropertyKey = "x", + PropertyValue = "x", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ [Fact] - public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void FieldRoundtrip_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", + }; + + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", }; - string 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 NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + 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", }; - 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 expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + 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", }; - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + 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 InvalidEnumValidationThrows_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + > + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); } - [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + [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 + ) { - 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", - Prorate = true, - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + // 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 NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() - { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, - Name = "Annual fee", - ScalableMatrixWithTieredPricingConfig = new() - { - FirstDimension = "first_dimension", - MatrixScalingFactors = - [ - new() - { - FirstDimensionValue = "first_dimension_value", - ScalingFactor = "scaling_factor", - SecondDimensionValue = "second_dimension_value", - }, - ], - Tiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ], - SecondDimension = "second_dimension", - }, - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + 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 NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - 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", + 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - 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 = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 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 MinimumSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - 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 = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -5610,73 +7675,49 @@ public void MinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - 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 = 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 PercentSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -5705,35 +7746,95 @@ public void PercentSerializationRoundtripWorks() 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 EventOutputSerializationRoundtripWorks() + public void SerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, + 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() @@ -5762,41 +7863,34 @@ public void EventOutputSerializationRoundtripWorks() 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); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Subscriptions::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() @@ -5825,28 +7919,29 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig expectedBulkWithFiltersConfig = - new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }; + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + 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() @@ -5855,7 +7950,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -5876,116 +7971,259 @@ 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(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(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); + 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(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(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + 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 SerializationRoundtrip_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.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", - }; + TieredWithProrationConfig = new( + [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] + ), - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; - Assert.Equal(model, deserialized); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, + Subscriptions::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() @@ -6014,383 +8252,260 @@ 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 - ); - Assert.NotNull(deserialized); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration copied = + new(model); - 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" }, - ], - }; + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; + 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); + } - 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)); + [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.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest + : TestBase +{ [Fact] - public void Validation_Works() + public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - model.Validate(); + 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 OptionalNullablePropertiesUnsetAreNotSet_Works() + public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - BulkWithFiltersConfig = new() - { - 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", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - BulkWithFiltersConfig = new() - { - 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", + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - model.Validate(); + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - BulkWithFiltersConfig = new() - { - 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, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + model.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig { - BulkWithFiltersConfig = new() - { - 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, + Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; - List expectedFilters = - [ - new() { PropertyKey = "x", PropertyValue = "x" }, - ]; - List expectedTiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ]; + string expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "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++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(expectedUnitAmount, model.UnitAmount); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6402,97 +8517,329 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], + 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); - 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 expectedTierLowerBound = "tier_lower_bound"; + string expectedUnitAmount = "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++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + { + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest + : TestBase +{ + [Fact] + public void UnitValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + value.Validate(); + } + + [Fact] + public void TieredValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedTieredConversionRateConfig() + { + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); + } + + [Fact] + public void UnitSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void TieredSerializationRoundtripWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig 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 SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfig + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + 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", }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilterTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() { - PropertyKey = "x", - PropertyValue = "x", + 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"; - string expectedPropertyKey = "x"; - string expectedPropertyValue = "x"; + 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(expectedPropertyKey, model.PropertyKey); - Assert.Equal(expectedPropertyValue, model.PropertyValue); + Assert.Equal(value, model.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, model.ReferenceID); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -6504,203 +8851,457 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigFilter + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - PropertyKey = "x", - PropertyValue = "x", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); 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 + ApiEnum< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + > expectedCadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + new() { - PropertyKey = "x", - PropertyValue = "x", - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTierTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + string expectedItemID = "item_id"; + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "grouped_with_min_max_thresholds" + ); + string expectedName = "Annual fee"; + string expectedBillableMetricID = "billable_metric_id"; + bool expectedBilledInAdvance = true; + NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }; + double expectedConversionRate = 0; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + new SharedUnitConversionRateConfig() { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + 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"; - string expectedUnitAmount = "unit_amount"; - string expectedTierLowerBound = "tier_lower_bound"; + 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(expectedUnitAmount, model.UnitAmount); - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", }; - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", }; - 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); + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", - TierLowerBound = "tier_lower_bound", + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, + ItemID = "item_id", + Name = "Annual fee", }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", + 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, }; - Assert.Null(model.TierLowerBound); - Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() + public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", + 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 OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersBulkWithFiltersConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds { - UnitAmount = "unit_amount", - - TierLowerBound = null, + 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", }; - 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::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest + : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; value.Validate(); } @@ -6711,7 +9312,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -6721,38 +9322,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -6765,14 +9366,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence > >(json, ModelBase.SerializerOptions); @@ -6780,13 +9381,126 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; + + Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedMaximumCharge, model.MaximumCharge); + Assert.Equal(expectedMinimumCharge, model.MinimumCharge); + Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); + } + + [Fact] + public void FieldRoundtripThroughSerialization_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedGroupingKey = "x"; + string expectedMaximumCharge = "maximum_charge"; + string expectedMinimumCharge = "minimum_charge"; + string expectedPerUnitRate = "per_unit_rate"; + + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); + Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); + Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }; + + model.Validate(); + } + + [Fact] + public void 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::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6798,7 +9512,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6819,7 +9533,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6827,7 +9541,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6838,7 +9552,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -6855,7 +9569,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -6864,21 +9578,26 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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() @@ -6907,20 +9626,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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); 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 +9657,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -6950,14 +9678,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(expectedTieredWithProrationConfig, model.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -6969,6 +9701,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +9717,19 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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() @@ -7021,13 +9758,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 +9777,19 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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() @@ -7076,13 +9818,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 +9833,22 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement( + "cumulative_grouped_allocation" + ); 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 +9857,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7127,14 +9878,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(expectedTieredWithProrationConfig, deserialized.TieredWithProrationConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -7149,6 +9904,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +9920,19 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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() @@ -7201,6 +9961,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -7212,15 +9973,19 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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" }] - ), }; Assert.Null(model.BillableMetricID); @@ -7245,6 +10010,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10022,19 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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" }] - ), }; model.Validate(); @@ -7273,15 +10044,19 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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 = null, BilledInAdvance = null, @@ -7294,6 +10069,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -7320,6 +10096,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +10108,19 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.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 = null, BilledInAdvance = null, @@ -7351,44 +10133,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::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, + ItemID = "item_id", + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation copied = + new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadenceTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; value.Validate(); } @@ -7399,7 +10238,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -7409,38 +10248,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -7453,14 +10292,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence > >(json, ModelBase.SerializerOptions); @@ -7468,42 +10307,47 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; + string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTiers.Count, model.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], model.Tiers[i]); - } + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -7515,130 +10359,74 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - List expectedTiers = - [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - ]; - - Assert.Equal(expectedTiers.Count, deserialized.Tiers.Count); - for (int i = 0; i < expectedTiers.Count; i++) - { - Assert.Equal(expectedTiers[i], deserialized.Tiers[i]); - } - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig - { - Tiers = [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }], - }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTierTest - : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; - - string expectedTierLowerBound = "tier_lower_bound"; + string expectedCumulativeAllocation = "cumulative_allocation"; + string expectedGroupAllocation = "group_allocation"; + string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; - Assert.Equal(expectedTierLowerBound, model.TierLowerBound); - Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); + Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); } [Fact] - public void SerializationRoundtrip_Works() + public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - TierLowerBound = "tier_lower_bound", + 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); + model.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig { - TierLowerBound = "tier_lower_bound", + 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 expectedTierLowerBound = "tier_lower_bound"; - string expectedUnitAmount = "unit_amount"; - - Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); - Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); - } - - [Fact] - public void Validation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier - { - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7650,7 +10438,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7671,7 +10459,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7679,7 +10467,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7690,7 +10478,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -7707,7 +10495,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -7716,23 +10504,26 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -7764,27 +10555,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::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7794,7 +10585,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -7815,14 +10606,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( - expectedGroupedWithMinMaxThresholdsConfig, - model.GroupedWithMinMaxThresholdsConfig - ); + Assert.Equal(expectedDailyCreditAllowanceConfig, model.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); @@ -7837,6 +10626,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,16 +10642,20 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -7893,13 +10687,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,16 +10706,20 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -7952,13 +10751,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 +10766,20 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig expectedGroupedWithMinMaxThresholdsConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig expectedDailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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( - "grouped_with_min_max_thresholds" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -7990,7 +10789,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8011,14 +10810,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( - expectedGroupedWithMinMaxThresholdsConfig, - deserialized.GroupedWithMinMaxThresholdsConfig - ); + Assert.Equal(expectedDailyCreditAllowanceConfig, deserialized.DailyCreditAllowanceConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); @@ -8036,6 +10833,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,16 +10849,20 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -8092,6 +10894,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8103,16 +10906,20 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -8140,6 +10947,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,16 +10959,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -8172,16 +10985,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -8197,6 +11014,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -8223,6 +11041,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,16 +11053,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], }, ItemID = "item_id", Name = "Annual fee", @@ -8258,44 +11082,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 SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadenceTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > value = rawValue; value.Validate(); } @@ -8306,7 +11191,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -8316,38 +11201,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -8360,14 +11245,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -8375,47 +11260,62 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DailyAllowance = "daily_allowance", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + EventDayProperty = "x", + MatrixValues = [new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }], }; - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + 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(expectedGroupingKey, model.GroupingKey); - Assert.Equal(expectedMaximumCharge, model.MaximumCharge); - Assert.Equal(expectedMinimumCharge, model.MinimumCharge); - Assert.Equal(expectedPerUnitRate, model.PerUnitRate); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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 ); @@ -8427,56 +11327,193 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + 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); - string expectedGroupingKey = "x"; - string expectedMaximumCharge = "maximum_charge"; - string expectedMinimumCharge = "minimum_charge"; - string expectedPerUnitRate = "per_unit_rate"; + 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(expectedGroupingKey, deserialized.GroupingKey); - Assert.Equal(expectedMaximumCharge, deserialized.MaximumCharge); - Assert.Equal(expectedMinimumCharge, deserialized.MinimumCharge); - Assert.Equal(expectedPerUnitRate, deserialized.PerUnitRate); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + { + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + 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 Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + { + DimensionValues = ["string"], + UnitAmount = "unit_amount", + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", + DimensionValues = ["string"], + UnitAmount = "unit_amount", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8488,7 +11525,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8509,7 +11546,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8517,7 +11554,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8528,7 +11565,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -8545,7 +11582,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8554,25 +11591,26 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8602,27 +11640,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::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8632,7 +11671,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8653,15 +11692,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( - expectedCumulativeGroupedAllocationConfig, - model.CumulativeGroupedAllocationConfig - ); 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); @@ -8675,6 +11712,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -8690,18 +11728,20 @@ public void FieldRoundtrip_Works() public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8731,13 +11771,14 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -8749,18 +11790,20 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8790,13 +11833,14 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -8804,21 +11848,21 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig expectedCumulativeGroupedAllocationConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual; + string expectedItemID = "item_id"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig expectedMeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement( - "cumulative_grouped_allocation" - ); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("metered_allowance"); string expectedName = "Annual fee"; string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; @@ -8828,7 +11872,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -8849,15 +11893,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( - expectedCumulativeGroupedAllocationConfig, - deserialized.CumulativeGroupedAllocationConfig - ); 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); @@ -8874,6 +11916,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -8889,18 +11932,20 @@ public void FieldRoundtripThroughSerialization_Works() public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -8930,6 +11975,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -8941,18 +11987,20 @@ public void Validation_Works() public void OptionalNullablePropertiesUnsetAreNotSet_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", }; @@ -8978,6 +12026,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -8988,18 +12038,20 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() public void OptionalNullablePropertiesUnsetValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", }; @@ -9010,18 +12062,20 @@ public void OptionalNullablePropertiesUnsetValidation_Works() public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -9035,6 +12089,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9061,6 +12116,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -9071,18 +12128,20 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() public void OptionalNullablePropertiesSetToNullValidation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, + ItemID = "item_id", + MeteredAllowanceConfig = new() { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }, - ItemID = "item_id", Name = "Annual fee", BillableMetricID = null, @@ -9096,44 +12155,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 SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadenceTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > value = rawValue; value.Validate(); } @@ -9144,7 +12261,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9154,38 +12271,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -9198,14 +12315,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > >(json, ModelBase.SerializerOptions); @@ -9213,47 +12330,55 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - string expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedCumulativeAllocation, model.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, model.GroupAllocation); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + 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 ); @@ -9265,56 +12390,158 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + 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 expectedCumulativeAllocation = "cumulative_allocation"; - string expectedGroupAllocation = "group_allocation"; + string expectedAllowanceGroupingValue = "x"; + string expectedConsumptionGroupingValue = "x"; string expectedGroupingKey = "x"; string expectedUnitAmount = "unit_amount"; + string expectedAllowanceDisplayName = "x"; + string expectedConsumptionDisplayName = "x"; - Assert.Equal(expectedCumulativeAllocation, deserialized.CumulativeAllocation); - Assert.Equal(expectedGroupAllocation, deserialized.GroupAllocation); + 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::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + { + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", + GroupingKey = "x", + 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 Validation_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", + AllowanceGroupingValue = "x", + ConsumptionGroupingValue = "x", GroupingKey = "x", UnitAmount = "unit_amount", + AllowanceDisplayName = "x", + ConsumptionDisplayName = "x", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9326,7 +12553,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9347,7 +12574,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9355,7 +12582,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9366,7 +12593,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -9383,7 +12610,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -9392,18 +12619,18 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9432,20 +12659,21 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9454,7 +12682,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9475,14 +12703,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); Assert.Equal(expectedItemID, model.ItemID); - Assert.Equal(expectedMinimumConfig, model.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); + Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -9494,6 +12723,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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,13 +12738,13 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9543,13 +12773,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,13 +12791,13 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9595,13 +12826,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,14 +12841,14 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; string expectedItemID = "item_id"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig expectedMinimumConfig = - new() { MinimumAmount = "minimum_amount", Prorated = true }; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("minimum"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); string expectedName = "Annual fee"; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = + new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -9625,7 +12857,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -9646,14 +12878,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.Equal(expectedMinimumConfig, deserialized.MinimumConfig); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); + Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -9668,6 +12901,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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,13 +12916,13 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -9717,6 +12951,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -9727,13 +12962,13 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -9758,6 +12993,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,13 +13004,13 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), }; model.Validate(); @@ -9782,13 +13019,13 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9801,6 +13038,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -9827,6 +13065,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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,13 +13076,13 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -9855,43 +13095,92 @@ public void OptionalNullablePropertiesSetToNullValidation_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; model.Validate(); } + + [Fact] + public void CopyConstructor_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + PercentConfig = new(0), + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent copied = new(model); + + Assert.Equal(model, copied); + } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; value.Validate(); } @@ -9902,7 +13191,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -9912,38 +13201,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -9956,14 +13245,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > >(json, ModelBase.SerializerOptions); @@ -9971,38 +13260,34 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Percent = 0, }; - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedProrated, model.Prorated); + Assert.Equal(expectedPercent, model.Percent); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Percent = 0, }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10014,104 +13299,59 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - Prorated = true, + Percent = 0, }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedMinimumAmount = "minimum_amount"; - bool expectedProrated = true; + double expectedPercent = 0; - Assert.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedProrated, deserialized.Prorated); + Assert.Equal(expectedPercent, deserialized.Percent); } [Fact] public void Validation_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - Prorated = true, - }; - - model.Validate(); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetAreNotSet_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - }; - - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", + Percent = 0, }; model.Validate(); } [Fact] - public void OptionalNonNullablePropertiesSetToNullAreNotSet_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, + Percent = 0, }; - Assert.Null(model.Prorated); - Assert.False(model.RawData.ContainsKey("prorated")); - } - - [Fact] - public void OptionalNonNullablePropertiesSetToNullValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig - { - MinimumAmount = "minimum_amount", - - // Null should be interpreted as omitted for these properties - Prorated = null, - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig copied = + new(model); - model.Validate(); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10123,7 +13363,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10144,7 +13384,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10152,7 +13392,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10163,7 +13403,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10180,7 +13420,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10189,18 +13429,23 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10229,20 +13474,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::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10251,7 +13502,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10272,14 +13523,15 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, model.Cadence); + Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); Assert.Equal(expectedItemID, model.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedPercentConfig, model.PercentConfig); Assert.Equal(expectedBillableMetricID, model.BillableMetricID); Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); @@ -10291,6 +13543,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, model.LicenseTypeID); Assert.NotNull(model.Metadata); Assert.Equal(expectedMetadata.Count, model.Metadata.Count); foreach (var item in expectedMetadata) @@ -10305,13 +13558,18 @@ public void FieldRoundtrip_Works() [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10340,13 +13598,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 ); @@ -10357,13 +13616,18 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10392,13 +13656,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 ); @@ -10406,14 +13671,19 @@ public void FieldRoundtripThroughSerialization_Works() ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = + new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("percent"); + JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); string expectedName = "Annual fee"; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig expectedPercentConfig = - new(0); string expectedBillableMetricID = "billable_metric_id"; bool expectedBilledInAdvance = true; NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() @@ -10422,7 +13692,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10443,14 +13713,15 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; + string expectedLicenseTypeID = "license_type_id"; Dictionary expectedMetadata = new() { { "foo", "string" } }; string expectedReferenceID = "reference_id"; Assert.Equal(expectedCadence, deserialized.Cadence); + Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); Assert.Equal(expectedItemID, deserialized.ItemID); Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedPercentConfig, deserialized.PercentConfig); Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); @@ -10465,6 +13736,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); + Assert.Equal(expectedLicenseTypeID, deserialized.LicenseTypeID); Assert.NotNull(deserialized.Metadata); Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); foreach (var item in expectedMetadata) @@ -10479,13 +13751,18 @@ public void FieldRoundtripThroughSerialization_Works() [Fact] public void Validation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -10514,6 +13791,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -10524,13 +13802,18 @@ public void Validation_Works() [Fact] public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; Assert.Null(model.BillableMetricID); @@ -10555,6 +13838,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.False(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10564,13 +13849,18 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), }; model.Validate(); @@ -10579,13 +13869,18 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10598,6 +13893,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -10624,6 +13920,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); Assert.Null(model.Metadata); Assert.True(model.RawData.ContainsKey("metadata")); Assert.Null(model.ReferenceID); @@ -10633,13 +13931,18 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercent + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", Name = "Annual fee", - PercentConfig = new(0), BillableMetricID = null, BilledInAdvance = null, @@ -10652,43 +13955,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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase { [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; value.Validate(); } @@ -10699,7 +14058,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -10709,38 +14068,38 @@ public void InvalidEnumValidationThrows_Works() [Theory] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime )] [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom )] public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence rawValue + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue ) { // force implicit conversion because Theory can't do that for us ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > value = rawValue; string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -10753,14 +14112,14 @@ public void InvalidEnumSerializationRoundtrip_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence > >(json, ModelBase.SerializerOptions); @@ -10768,34 +14127,43 @@ public void InvalidEnumSerializationRoundtrip_Works() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigTest : TestBase +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest + : TestBase { [Fact] public void FieldRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; - Assert.Equal(expectedPercent, model.Percent); + Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, model.GroupingKey); } [Fact] public void SerializationRoundtrip_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -10807,44 +14175,129 @@ public void SerializationRoundtrip_Works() public void FieldRoundtripThroughSerialization_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - double expectedPercent = 0; + string expectedUnitRatingKey = "x"; + string expectedDefaultUnitRate = "default_unit_rate"; + string expectedGroupingKey = "grouping_key"; + + Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); + Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); + Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + } + + [Fact] + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + }; + + Assert.Null(model.DefaultUnitRate); + Assert.False(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.False(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", + + DefaultUnitRate = null, + GroupingKey = null, + }; + + Assert.Null(model.DefaultUnitRate); + Assert.True(model.RawData.ContainsKey("default_unit_rate")); + Assert.Null(model.GroupingKey); + Assert.True(model.RawData.ContainsKey("grouping_key")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + { + UnitRatingKey = "x", - Assert.Equal(expectedPercent, deserialized.Percent); + DefaultUnitRate = null, + GroupingKey = null, + }; + + model.Validate(); } [Fact] - public void Validation_Works() + public void CopyConstructor_Works() { var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig + new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig { - Percent = 0, + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }; - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig copied = + new(model); + + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigTest +public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest : TestBase { [Fact] public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10856,7 +14309,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10877,7 +14330,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -10885,7 +14338,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10896,7 +14349,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -10913,7 +14366,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -10922,179 +14375,88 @@ public void TieredSerializationRoundtripWorks() } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputTest : TestBase +public class BillingCycleAlignmentTest : TestBase { + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + value.Validate(); + } + [Fact] - public void FieldRoundtrip_Works() + public void InvalidEnumValidationThrows_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }; - string expectedExternalPriceID = "external_price_id"; - double expectedFixedPriceQuantity = 0; - string expectedInvoiceGroupingKey = "x"; - NewBillingCycleConfiguration expectedInvoicingCycleConfiguration = new() + Assert.NotNull(value); + Assert.Throws(() => value.Validate()); + } + + [Theory] + [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] + [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] + [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] + public void SerializationRoundtrip_Works(Subscriptions::BillingCycleAlignment rawValue) + { + // force implicit conversion because Theory can't do that for us + ApiEnum value = rawValue; + + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } + + [Fact] + public void InvalidEnumSerializationRoundtrip_Works() + { + var value = JsonSerializer.Deserialize< + ApiEnum + >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); + string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = JsonSerializer.Deserialize< + ApiEnum + >(json, ModelBase.SerializerOptions); + + Assert.Equal(value, deserialized); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentID = "h74gfhdjvn7ujokd", }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, model.Cadence); - Assert.Equal(expectedEventOutputConfig, model.EventOutputConfig); - Assert.Equal(expectedItemID, model.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, model.ModelType)); - Assert.Equal(expectedName, model.Name); - Assert.Equal(expectedBillableMetricID, model.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, model.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, model.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, model.ConversionRate); - Assert.Equal(expectedConversionRateConfig, model.ConversionRateConfig); - Assert.Equal(expectedCurrency, model.Currency); - Assert.Equal(expectedDimensionalPriceConfiguration, model.DimensionalPriceConfiguration); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, model.InvoicingCycleConfiguration); - Assert.NotNull(model.Metadata); - Assert.Equal(expectedMetadata.Count, model.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(model.Metadata.TryGetValue(item.Key, out var value)); + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - Assert.Equal(value, model.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, model.ReferenceID); + Assert.Equal(expectedAdjustmentID, model.AdjustmentID); } [Fact] public void SerializationRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment + { + AdjustmentID = "h74gfhdjvn7ujokd", }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11105,246 +14467,137 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + AdjustmentID = "h74gfhdjvn7ujokd", }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > expectedCadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig expectedEventOutputConfig = - new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; - string expectedItemID = "item_id"; - JsonElement expectedModelType = JsonSerializer.SerializeToElement("event_output"); - string expectedName = "Annual fee"; - string expectedBillableMetricID = "billable_metric_id"; - bool expectedBilledInAdvance = true; - NewBillingCycleConfiguration expectedBillingCycleConfiguration = new() + string expectedAdjustmentID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + AdjustmentID = "h74gfhdjvn7ujokd", }; - double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig expectedConversionRateConfig = - new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }; - string expectedCurrency = "currency"; - NewDimensionalPriceConfiguration expectedDimensionalPriceConfiguration = new() + + model.Validate(); + } + + [Fact] + public void CopyConstructor_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() + + Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment copied = new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - Dictionary expectedMetadata = new() { { "foo", "string" } }; - string expectedReferenceID = "reference_id"; - Assert.Equal(expectedCadence, deserialized.Cadence); - Assert.Equal(expectedEventOutputConfig, deserialized.EventOutputConfig); - Assert.Equal(expectedItemID, deserialized.ItemID); - Assert.True(JsonElement.DeepEquals(expectedModelType, deserialized.ModelType)); - Assert.Equal(expectedName, deserialized.Name); - Assert.Equal(expectedBillableMetricID, deserialized.BillableMetricID); - Assert.Equal(expectedBilledInAdvance, deserialized.BilledInAdvance); - Assert.Equal(expectedBillingCycleConfiguration, deserialized.BillingCycleConfiguration); - Assert.Equal(expectedConversionRate, deserialized.ConversionRate); - Assert.Equal(expectedConversionRateConfig, deserialized.ConversionRateConfig); - Assert.Equal(expectedCurrency, deserialized.Currency); - Assert.Equal( - expectedDimensionalPriceConfiguration, - deserialized.DimensionalPriceConfiguration - ); - Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); - Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); - Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); - Assert.Equal(expectedInvoicingCycleConfiguration, deserialized.InvoicingCycleConfiguration); - Assert.NotNull(deserialized.Metadata); - Assert.Equal(expectedMetadata.Count, deserialized.Metadata.Count); - foreach (var item in expectedMetadata) - { - Assert.True(deserialized.Metadata.TryGetValue(item.Key, out var value)); + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(value, deserialized.Metadata[item.Key]); - } - Assert.Equal(expectedReferenceID, deserialized.ReferenceID); + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] - public void Validation_Works() + public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", + PriceID = "h74gfhdjvn7ujokd", }; - model.Validate(); + string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + json, + ModelBase.SerializerOptions + ); + + Assert.Equal(model, deserialized); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", }; - Assert.Null(model.BillableMetricID); - Assert.False(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.False(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.False(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.False(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.False(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + Assert.NotNull(deserialized); + + string expectedExternalPriceID = "external_price_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; + + Assert.Equal(expectedExternalPriceID, deserialized.ExternalPriceID); + Assert.Equal(expectedPriceID, deserialized.PriceID); + } + + [Fact] + public void Validation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; + Assert.Null(model.ExternalPriceID); Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.False(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.False(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesUnsetValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - }; + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; model.Validate(); } @@ -11352,242 +14605,133 @@ public void OptionalNullablePropertiesUnsetValidation_Works() [Fact] public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PriceID = null, }; - Assert.Null(model.BillableMetricID); - Assert.True(model.RawData.ContainsKey("billable_metric_id")); - Assert.Null(model.BilledInAdvance); - Assert.True(model.RawData.ContainsKey("billed_in_advance")); - Assert.Null(model.BillingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); - Assert.Null(model.ConversionRate); - Assert.True(model.RawData.ContainsKey("conversion_rate")); - Assert.Null(model.ConversionRateConfig); - Assert.True(model.RawData.ContainsKey("conversion_rate_config")); - Assert.Null(model.Currency); - Assert.True(model.RawData.ContainsKey("currency")); - Assert.Null(model.DimensionalPriceConfiguration); - Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); Assert.Null(model.ExternalPriceID); Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.FixedPriceQuantity); - Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); - Assert.Null(model.InvoiceGroupingKey); - Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); - Assert.Null(model.InvoicingCycleConfiguration); - Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); - Assert.Null(model.Metadata); - Assert.True(model.RawData.ContainsKey("metadata")); - Assert.Null(model.ReferenceID); - Assert.True(model.RawData.ContainsKey("reference_id")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); } [Fact] public void OptionalNullablePropertiesSetToNullValidation_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, - EventOutputConfig = new() - { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }, - ItemID = "item_id", - Name = "Annual fee", - - BillableMetricID = null, - BilledInAdvance = null, - BillingCycleConfiguration = null, - ConversionRate = null, - ConversionRateConfig = null, - Currency = null, - DimensionalPriceConfiguration = null, ExternalPriceID = null, - FixedPriceQuantity = null, - InvoiceGroupingKey = null, - InvoicingCycleConfiguration = null, - Metadata = null, - ReferenceID = null, + PriceID = null, }; model.Validate(); } -} - -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceTest : TestBase -{ - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom - )] - public void Validation_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue - ) - { - // force implicit conversion because Theory can't do that for us - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > value = rawValue; - value.Validate(); - } [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime - )] - [InlineData( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom - )] - public void SerializationRoundtrip_Works( - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence rawValue - ) + public void CopyConstructor_Works() { - // 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); - } + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + { + ExternalPriceID = "external_price_id", + PriceID = "h74gfhdjvn7ujokd", + }; - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum< - string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence - > - >(json, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice copied = new(model); - Assert.Equal(value, deserialized); + Assert.Equal(model, copied); } } -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigTest - : TestBase +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase { [Fact] public void FieldRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; - - Assert.Equal(expectedUnitRatingKey, model.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, model.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, model.GroupingKey); + Assert.Equal(expectedAdjustment, model.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); } [Fact] public void SerializationRoundtrip_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -11598,520 +14742,738 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - string expectedUnitRatingKey = "x"; - string expectedDefaultUnitRate = "default_unit_rate"; - string expectedGroupingKey = "grouping_key"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = + new NewPercentageDiscount() + { + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }; + string expectedReplacesAdjustmentID = "replaces_adjustment_id"; - Assert.Equal(expectedUnitRatingKey, deserialized.UnitRatingKey); - Assert.Equal(expectedDefaultUnitRate, deserialized.DefaultUnitRate); - Assert.Equal(expectedGroupingKey, deserialized.GroupingKey); + Assert.Equal(expectedAdjustment, deserialized.Adjustment); + Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); } [Fact] public void Validation_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - UnitRatingKey = "x", - DefaultUnitRate = "default_unit_rate", - GroupingKey = "grouping_key", - }; + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; model.Validate(); } [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() + public void CopyConstructor_Works() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + { + Adjustment = new NewPercentageDiscount() { - 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")); - } + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, + }, + ReplacesAdjustmentID = "replaces_adjustment_id", + }; - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig - { - UnitRatingKey = "x", - }; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment copied = new(model); - model.Validate(); + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase +{ [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + public void NewPercentageDiscountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; - - Assert.Null(model.DefaultUnitRate); - Assert.True(model.RawData.ContainsKey("default_unit_rate")); - Assert.Null(model.GroupingKey); - Assert.True(model.RawData.ContainsKey("grouping_key")); + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewUsageDiscountValidationWorks() { - var model = - new Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() { - UnitRatingKey = "x", - - DefaultUnitRate = null, - GroupingKey = null, + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, }; - - model.Validate(); + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigTest - : TestBase -{ [Fact] - public void UnitValidationWorks() + public void NewAmountDiscountValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig 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(); } [Fact] - public void TieredValidationWorks() + public void NewMinimumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, }; value.Validate(); } [Fact] - public void UnitSerializationRoundtripWorks() + public void NewMaximumValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedUnitConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void TieredSerializationRoundtripWorks() + public void NewPercentageDiscountSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value = - new SharedTieredConversionRateConfig() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewPercentageDiscount() { - ConversionRateType = ConversionRateType.Tiered, - TieredConfig = new( - [ - new() - { - FirstUnit = 0, - UnitAmount = "unit_amount", - LastUnit = 0, - }, - ] - ), + AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, + PercentageDiscount = 0, + AppliesToAll = NewPercentageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewPercentageDiscountFilterField.PriceID, + Operator = NewPercentageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewPercentageDiscountPriceType.Usage, }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.Equal(value, deserialized); } -} - -public class BillingCycleAlignmentTest : TestBase -{ - [Theory] - [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] - [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] - [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] - public void Validation_Works(Subscriptions::BillingCycleAlignment rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - value.Validate(); - } - - [Fact] - public void InvalidEnumValidationThrows_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); - - Assert.NotNull(value); - Assert.Throws(() => value.Validate()); - } - - [Theory] - [InlineData(Subscriptions::BillingCycleAlignment.Unchanged)] - [InlineData(Subscriptions::BillingCycleAlignment.PlanChangeDate)] - [InlineData(Subscriptions::BillingCycleAlignment.StartOfMonth)] - public void SerializationRoundtrip_Works(Subscriptions::BillingCycleAlignment rawValue) - { - // force implicit conversion because Theory can't do that for us - ApiEnum value = rawValue; - - string json = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = JsonSerializer.Deserialize< - ApiEnum - >(json, ModelBase.SerializerOptions); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void InvalidEnumSerializationRoundtrip_Works() - { - var value = JsonSerializer.Deserialize< - ApiEnum - >(JsonSerializer.SerializeToElement("invalid 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 NewUsageDiscountSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - AdjustmentID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewUsageDiscount() + { + AdjustmentType = NewUsageDiscountAdjustmentType.UsageDiscount, + UsageDiscount = 0, + AppliesToAll = NewUsageDiscountAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewUsageDiscountFilterField.PriceID, + Operator = NewUsageDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewUsageDiscountPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); - Assert.NotNull(deserialized); - - string expectedAdjustmentID = "h74gfhdjvn7ujokd"; - - Assert.Equal(expectedAdjustmentID, deserialized.AdjustmentID); - } - - [Fact] - public void Validation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemoveAdjustment - { - AdjustmentID = "h74gfhdjvn7ujokd", - }; - model.Validate(); + Assert.Equal(value, deserialized); } -} -public class SubscriptionSchedulePlanChangeParamsRemovePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewAmountDiscountSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string expectedExternalPriceID = "external_price_id"; - string expectedPriceID = "h74gfhdjvn7ujokd"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewAmountDiscount() + { + AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, + AmountDiscount = "amount_discount", + AppliesToAll = AppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewAmountDiscountFilterField.PriceID, + Operator = NewAmountDiscountFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = PriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); - Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); - Assert.Equal(expectedPriceID, model.PriceID); + Assert.Equal(value, deserialized); } [Fact] - public void SerializationRoundtrip_Works() + public void NewMinimumSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string json = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMinimum() + { + AdjustmentType = NewMinimumAdjustmentType.Minimum, + ItemID = "item_id", + MinimumAmount = "minimum_amount", + AppliesToAll = NewMinimumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMinimumFilterField.PriceID, + Operator = NewMinimumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMinimumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( - json, + JsonSerializer.Deserialize( + element, ModelBase.SerializerOptions ); - Assert.Equal(model, deserialized); + Assert.Equal(value, deserialized); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewMaximumSerializationRoundtripWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = "external_price_id", - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = + new NewMaximum() + { + AdjustmentType = NewMaximumAdjustmentType.Maximum, + MaximumAmount = "maximum_amount", + AppliesToAll = NewMaximumAppliesToAll.True, + AppliesToItemIds = ["item_1", "item_2"], + AppliesToPriceIds = ["price_1", "price_2"], + Currency = "currency", + Filters = + [ + new() + { + Field = NewMaximumFilterField.PriceID, + Operator = NewMaximumFilterOperator.Includes, + Values = ["string"], + }, + ], + IsInvoiceLevel = true, + PriceType = NewMaximumPriceType.Usage, + }; + string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + 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); + Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase +{ [Fact] - public void Validation_Works() + public void FieldRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + 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", }; - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesUnsetAreNotSet_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - Assert.Null(model.ExternalPriceID); - Assert.False(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.False(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesUnsetValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice { }; - - model.Validate(); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice - { - ExternalPriceID = null, - PriceID = null, - }; - - Assert.Null(model.ExternalPriceID); - Assert.True(model.RawData.ContainsKey("external_price_id")); - Assert.Null(model.PriceID); - Assert.True(model.RawData.ContainsKey("price_id")); - } - - [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsRemovePrice + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() { - ExternalPriceID = null, - PriceID = null, + 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", }; - - model.Validate(); - } -} - -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentTest : TestBase -{ - [Fact] - public void FieldRoundtrip_Works() - { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment - { - Adjustment = new NewPercentageDiscount() + List expectedDiscounts = + [ + 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, + DiscountType = Subscriptions::DiscountType.Percentage, + AmountDiscount = "amount_discount", + PercentageDiscount = 0.15, + UsageDiscount = 0, }, - ReplacesAdjustmentID = "replaces_adjustment_id", + ]; + string expectedExternalPriceID = "external_price_id"; + double expectedFixedPriceQuantity = 2; + string expectedMaximumAmount = "1.23"; + Dictionary expectedMetricParameterOverrides = new() + { + { "foo", JsonSerializer.SerializeToElement("bar") }, }; - - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + string expectedMinimumAmount = "1.23"; + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice expectedPrice = + 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", }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + string expectedPriceID = "h74gfhdjvn7ujokd"; - Assert.Equal(expectedAdjustment, model.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, model.ReplacesAdjustmentID); + Assert.Equal(expectedReplacesPriceID, model.ReplacesPriceID); + Assert.Equal(expectedAllocationPrice, model.AllocationPrice); + Assert.NotNull(model.Discounts); + Assert.Equal(expectedDiscounts.Count, model.Discounts.Count); + for (int i = 0; i < expectedDiscounts.Count; i++) + { + Assert.Equal(expectedDiscounts[i], model.Discounts[i]); + } + Assert.Equal(expectedExternalPriceID, model.ExternalPriceID); + Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); + Assert.Equal(expectedMaximumAmount, model.MaximumAmount); + Assert.NotNull(model.MetricParameterOverrides); + Assert.Equal(expectedMetricParameterOverrides.Count, model.MetricParameterOverrides.Count); + foreach (var item in expectedMetricParameterOverrides) + { + Assert.True(model.MetricParameterOverrides.TryGetValue(item.Key, out var value)); + + Assert.True(JsonElement.DeepEquals(value, model.MetricParameterOverrides[item.Key])); + } + Assert.Equal(expectedMinimumAmount, model.MinimumAmount); + Assert.Equal(expectedPrice, model.Price); + Assert.Equal(expectedPriceID, model.PriceID); } [Fact] public void SerializationRoundtrip_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Adjustment = new NewPercentageDiscount() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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( + JsonSerializer.Deserialize( json, ModelBase.SerializerOptions ); @@ -12122,460 +15484,886 @@ public void SerializationRoundtrip_Works() [Fact] public void FieldRoundtripThroughSerialization_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - Adjustment = new NewPercentageDiscount() + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, + ItemID = "item_id", + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + PerUnitCostBasis = "per_unit_cost_basis", }, - ReplacesAdjustmentID = "replaces_adjustment_id", + 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( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); Assert.NotNull(deserialized); - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment expectedAdjustment = - new NewPercentageDiscount() + string expectedReplacesPriceID = "replaces_price_id"; + NewAllocationPrice expectedAllocationPrice = new() + { + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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::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(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::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 = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string expectedReplacesAdjustmentID = "replaces_adjustment_id"; + 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.Equal(expectedAdjustment, deserialized.Adjustment); - Assert.Equal(expectedReplacesAdjustmentID, deserialized.ReplacesAdjustmentID); + model.Validate(); } [Fact] - public void Validation_Works() + public void OptionalNullablePropertiesUnsetAreNotSet_Works() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustment + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice { - 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", + ReplacesPriceID = "replaces_price_id", + }; + + Assert.Null(model.AllocationPrice); + Assert.False(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.False(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.False(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.False(model.RawData.ContainsKey("metric_parameter_overrides")); + Assert.Null(model.MinimumAmount); + Assert.False(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.False(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.False(model.RawData.ContainsKey("price_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", }; model.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentTest : TestBase -{ [Fact] - public void NewPercentageDiscountValidationWorks() + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() { - 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(); + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + Assert.Null(model.AllocationPrice); + Assert.True(model.RawData.ContainsKey("allocation_price")); + Assert.Null(model.Discounts); + Assert.True(model.RawData.ContainsKey("discounts")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.MaximumAmount); + Assert.True(model.RawData.ContainsKey("maximum_amount")); + Assert.Null(model.MetricParameterOverrides); + Assert.True(model.RawData.ContainsKey("metric_parameter_overrides")); + Assert.Null(model.MinimumAmount); + Assert.True(model.RawData.ContainsKey("minimum_amount")); + Assert.Null(model.Price); + Assert.True(model.RawData.ContainsKey("price")); + Assert.Null(model.PriceID); + Assert.True(model.RawData.ContainsKey("price_id")); } [Fact] - public void NewUsageDiscountValidationWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - 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(); + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + + AllocationPrice = null, + Discounts = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + MaximumAmount = null, + MetricParameterOverrides = null, + MinimumAmount = null, + Price = null, + PriceID = null, + }; + + model.Validate(); } [Fact] - public void NewAmountDiscountValidationWorks() + public void CopyConstructor_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewAmountDiscount() + var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice + { + ReplacesPriceID = "replaces_price_id", + AllocationPrice = new() { - AdjustmentType = NewAmountDiscountAdjustmentType.AmountDiscount, - AmountDiscount = "amount_discount", - AppliesToAll = AppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", + Amount = "10.00", + Cadence = Cadence.Monthly, + Currency = "USD", + CustomExpiration = new() + { + Duration = 0, + DurationUnit = CustomExpirationDurationUnit.Day, + }, + ExpiresAtEndOfCadence = true, Filters = [ new() { - Field = NewAmountDiscountFilterField.PriceID, - Operator = NewAmountDiscountFilterOperator.Includes, + Field = NewAllocationPriceFilterField.ItemID, + Operator = NewAllocationPriceFilterOperator.Includes, Values = ["string"], }, ], - IsInvoiceLevel = true, - PriceType = PriceType.Usage, - }; - value.Validate(); + 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::SubscriptionSchedulePlanChangeParamsReplacePrice copied = new(model); + + Assert.Equal(model, copied); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase +{ [Fact] - public void NewMinimumValidationWorks() + public void NewSubscriptionUnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionUnitPrice() { - AdjustmentType = NewMinimumAdjustmentType.Minimum, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - MinimumAmount = "minimum_amount", - AppliesToAll = NewMinimumAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], + 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 = 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 NewSubscriptionTieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewMaximum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredPrice() { - AdjustmentType = NewMaximumAdjustmentType.Maximum, - MaximumAmount = "maximum_amount", - AppliesToAll = NewMaximumAppliesToAll.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 = 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(); } [Fact] - public void NewPercentageDiscountSerializationRoundtripWorks() - { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value = - new NewPercentageDiscount() - { - AdjustmentType = NewPercentageDiscountAdjustmentType.PercentageDiscount, - PercentageDiscount = 0, - AppliesToAll = NewPercentageDiscountAppliesToAll.True, - AppliesToItemIds = ["item_1", "item_2"], - AppliesToPriceIds = ["price_1", "price_2"], - Currency = "currency", - Filters = - [ - new() - { - Field = NewPercentageDiscountFilterField.PriceID, - Operator = NewPercentageDiscountFilterOperator.Includes, - Values = ["string"], - }, - ], - IsInvoiceLevel = true, - PriceType = NewPercentageDiscountPriceType.Usage, - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); - } - - [Fact] - public void NewUsageDiscountSerializationRoundtripWorks() + public void NewSubscriptionBulkValidationWorks() { - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewAmountDiscountSerializationRoundtripWorks() + public void BulkWithFiltersValidationWorks() { - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewMinimumSerializationRoundtripWorks() + public void NewSubscriptionPackageValidationWorks() { - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } [Fact] - public void NewMaximumSerializationRoundtripWorks() + public void NewSubscriptionMatrixValidationWorks() { - 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( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePriceTest : TestBase -{ [Fact] - public void FieldRoundtrip_Works() + public void NewSubscriptionThresholdTotalAmountValidationWorks() { - 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() + 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 = 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"), }, - ], - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 2, - MaximumAmount = "1.23", - MinimumAmount = "1.23", - 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", + }; + value.Validate(); + } + + [Fact] + public void NewSubscriptionTieredPackageValidationWorks() + { + 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() @@ -12604,58 +16392,44 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; + }; + value.Validate(); + } - 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() + [Fact] + public void NewSubscriptionTieredWithMinimumValidationWorks() + { + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + TieredWithMinimumConfig = new() + { + Tiers = + [ + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + new() + { + MinimumAmount = "minimum_amount", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + HideZeroAmountTiers = true, + Prorate = true, + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -12684,77 +16458,32 @@ public void FieldRoundtrip_Works() 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.Equal(expectedMinimumAmount, model.MinimumAmount); - Assert.Equal(expectedPrice, model.Price); - Assert.Equal(expectedPriceID, model.PriceID); + value.Validate(); } [Fact] - public void SerializationRoundtrip_Works() + public void NewSubscriptionGroupedTieredValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - AllocationPrice = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - 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::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 +16512,43 @@ 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); - var deserialized = - JsonSerializer.Deserialize( - json, - ModelBase.SerializerOptions - ); - - Assert.Equal(model, deserialized); + }; + value.Validate(); } [Fact] - public void FieldRoundtripThroughSerialization_Works() + public void NewSubscriptionTieredPackageWithMinimumValidationWorks() { - 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::NewSubscriptionTieredPackageWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, + ModelType = + Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, Name = "Annual fee", - UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, + 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() @@ -12877,66 +16577,30 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", - }, - PriceID = "h74gfhdjvn7ujokd", - }; - - string element = JsonSerializer.Serialize(model, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.NotNull(deserialized); + }; + value.Validate(); + } - 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() + [Fact] + public void NewSubscriptionPackageWithAllocationValidationWorks() + { + 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 +16629,25 @@ public void FieldRoundtripThroughSerialization_Works() 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.Equal(expectedMinimumAmount, deserialized.MinimumAmount); - Assert.Equal(expectedPrice, deserialized.Price); - Assert.Equal(expectedPriceID, deserialized.PriceID); + value.Validate(); } [Fact] - public void Validation_Works() + public void NewSubscriptionUnitWithPercentValidationWorks() { - 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 +16676,82 @@ 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")); + }; + value.Validate(); } [Fact] - public void OptionalNullablePropertiesSetToNullValidation_Works() + public void NewSubscriptionMatrixWithAllocationValidationWorks() { - var model = new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePrice - { - ReplacesPriceID = "replaces_price_id", - - AllocationPrice = null, - Discounts = null, - ExternalPriceID = null, - FixedPriceQuantity = null, - MaximumAmount = null, - MinimumAmount = null, - Price = null, - PriceID = null, - }; - - model.Validate(); + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, + ItemID = "item_id", + MatrixWithAllocationConfig = new() + { + Allocation = "allocation", + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = + [ + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + ], + }, + ModelType = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + Name = "Annual fee", + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_id", + FixedPriceQuantity = 0, + InvoiceGroupingKey = "x", + InvoicingCycleConfiguration = new() + { + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + LicenseTypeID = "license_type_id", + Metadata = new Dictionary() { { "foo", "string" } }, + ReferenceID = "reference_id", + }; + value.Validate(); } -} -public class SubscriptionSchedulePlanChangeParamsReplacePricePriceTest : TestBase -{ [Fact] - public void NewSubscriptionUnitValidationWorks() + public void TieredWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.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() @@ -13207,6 +16780,7 @@ public void NewSubscriptionUnitValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13214,28 +16788,17 @@ public void NewSubscriptionUnitValidationWorks() } [Fact] - public void NewSubscriptionTieredValidationWorks() + public void NewSubscriptionUnitWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.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() @@ -13264,6 +16827,7 @@ public void NewSubscriptionTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13271,15 +16835,21 @@ public void NewSubscriptionTieredValidationWorks() } [Fact] - public void NewSubscriptionBulkValidationWorks() + public void NewSubscriptionGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13309,6 +16879,7 @@ public void NewSubscriptionBulkValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13316,23 +16887,21 @@ public void NewSubscriptionBulkValidationWorks() } [Fact] - public void BulkWithFiltersValidationWorks() + public void NewSubscriptionBulkWithProrationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + BulkWithProrationConfig = new( [ new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13362,6 +16931,7 @@ public void BulkWithFiltersValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13369,16 +16939,23 @@ public void BulkWithFiltersValidationWorks() } [Fact] - public void NewSubscriptionPackageValidationWorks() + public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13407,6 +16984,7 @@ public void NewSubscriptionPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13414,23 +16992,35 @@ public void NewSubscriptionPackageValidationWorks() } [Fact] - public void NewSubscriptionMatrixValidationWorks() + public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13460,6 +17050,7 @@ public void NewSubscriptionMatrixValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13467,25 +17058,81 @@ public void NewSubscriptionMatrixValidationWorks() } [Fact] - public void NewSubscriptionThresholdTotalAmountValidationWorks() + public void GroupedWithMinMaxThresholdsValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, + GroupedWithMinMaxThresholdsConfig = new() + { + GroupingKey = "x", + MaximumCharge = "maximum_charge", + MinimumCharge = "minimum_charge", + PerUnitRate = "per_unit_rate", + }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, Name = "Annual fee", - ThresholdTotalAmountConfig = new() + BillableMetricID = "billable_metric_id", + BilledInAdvance = true, + BillingCycleConfiguration = new() { - ConsumptionTable = + Duration = 0, + DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, + }, + ConversionRate = 0, + ConversionRateConfig = new SharedUnitConversionRateConfig() + { + ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, + UnitConfig = new("unit_amount"), + }, + Currency = "currency", + DimensionalPriceConfiguration = new() + { + DimensionValues = ["string"], + DimensionalPriceGroupID = "dimensional_price_group_id", + ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", + }, + ExternalPriceID = "external_price_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::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + { + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, + ItemID = "item_id", + MatrixWithDisplayNameConfig = new() + { + 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 = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13514,6 +17161,7 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13521,17 +17169,15 @@ public void NewSubscriptionThresholdTotalAmountValidationWorks() } [Fact] - public void NewSubscriptionTieredPackageValidationWorks() + public void NewSubscriptionGroupedTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.TieredPackage, - Name = "Annual fee", - TieredPackageConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.Annual, + GroupedTieredPackageConfig = new() { + GroupingKey = "x", PackageSize = "package_size", Tiers = [ @@ -13539,6 +17185,10 @@ public void NewSubscriptionTieredPackageValidationWorks() 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() @@ -13567,6 +17217,7 @@ public void NewSubscriptionTieredPackageValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13574,36 +17225,26 @@ public void NewSubscriptionTieredPackageValidationWorks() } [Fact] - public void NewSubscriptionTieredWithMinimumValidationWorks() + public void NewSubscriptionMaxGroupTieredPackageValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() - { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + { + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + 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 = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13632,6 +17273,7 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13639,24 +17281,34 @@ public void NewSubscriptionTieredWithMinimumValidationWorks() } [Fact] - public void NewSubscriptionGroupedTieredValidationWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.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 = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13685,6 +17337,7 @@ public void NewSubscriptionGroupedTieredValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13692,34 +17345,35 @@ public void NewSubscriptionGroupedTieredValidationWorks() } [Fact] - public void NewSubscriptionTieredPackageWithMinimumValidationWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.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, @@ -13749,6 +17403,7 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13756,22 +17411,29 @@ public void NewSubscriptionTieredPackageWithMinimumValidationWorks() } [Fact] - public void NewSubscriptionPackageWithAllocationValidationWorks() + public void NewSubscriptionCumulativeGroupedBulkValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - PackageWithAllocationConfig = new() - { - Allocation = "allocation", - PackageAmount = "package_amount", - PackageSize = "package_size", - }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13800,6 +17462,7 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13807,17 +17470,22 @@ public void NewSubscriptionPackageWithAllocationValidationWorks() } [Fact] - public void NewSubscriptionUnitWithPercentValidationWorks() + public void CumulativeGroupedAllocationValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, + CumulativeGroupedAllocationConfig = new() + { + CumulativeAllocation = "cumulative_allocation", + GroupAllocation = "group_allocation", + GroupingKey = "x", + UnitAmount = "unit_amount", + }, 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() @@ -13846,6 +17514,7 @@ public void NewSubscriptionUnitWithPercentValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13853,25 +17522,25 @@ public void NewSubscriptionUnitWithPercentValidationWorks() } [Fact] - public void NewSubscriptionMatrixWithAllocationValidationWorks() + public void DailyCreditAllowanceValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence.Annual, + DailyCreditAllowanceConfig = new() { - Allocation = "allocation", + DailyAllowance = "daily_allowance", DefaultUnitAmount = "default_unit_amount", Dimensions = ["string"], + EventDayProperty = "x", MatrixValues = [ new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ModelType = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -13901,6 +17570,7 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13908,18 +17578,24 @@ public void NewSubscriptionMatrixWithAllocationValidationWorks() } [Fact] - public void TieredWithProrationValidationWorks() + public void MeteredAllowanceValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.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() @@ -13948,6 +17624,7 @@ public void TieredWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -13955,17 +17632,21 @@ public void TieredWithProrationValidationWorks() } [Fact] - public void NewSubscriptionUnitWithProrationValidationWorks() + public void NewSubscriptionMinimumCompositeValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, ItemID = "item_id", + MinimumCompositeConfig = new() + { + MinimumAmount = "minimum_amount", + Prorated = true, + }, ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.UnitWithProration, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", - UnitWithProrationConfig = new("unit_amount"), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -13994,6 +17675,7 @@ public void NewSubscriptionUnitWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14001,22 +17683,16 @@ public void NewSubscriptionUnitWithProrationValidationWorks() } [Fact] - public void NewSubscriptionGroupedAllocationValidationWorks() + public void PercentValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() - { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", - }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14045,6 +17721,7 @@ public void NewSubscriptionGroupedAllocationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14052,21 +17729,20 @@ public void NewSubscriptionGroupedAllocationValidationWorks() } [Fact] - public void NewSubscriptionBulkWithProrationValidationWorks() + public void EventOutputValidationWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() + { + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", + }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14096,6 +17772,7 @@ public void NewSubscriptionBulkWithProrationValidationWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14103,23 +17780,16 @@ public void NewSubscriptionBulkWithProrationValidationWorks() } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumValidationWorks() + public void NewSubscriptionUnitSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::NewSubscriptionUnitPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() - { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", - }, + Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, + ModelType = Subscriptions::NewSubscriptionUnitPriceModelType.Unit, Name = "Annual fee", + UnitConfig = new() { UnitAmount = "unit_amount", Prorated = true }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14148,43 +17818,43 @@ 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 + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumValidationWorks() + public void NewSubscriptionTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + new Subscriptions::NewSubscriptionTieredPrice() { - Cadence = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, - GroupedWithMeteredMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + ItemID = "item_id", + ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + Name = "Annual fee", + TieredConfig = new() { - GroupingKey = "x", - MinimumUnitAmount = "minimum_unit_amount", - PricingKey = "pricing_key", - ScalingFactors = + Tiers = [ new() { - ScalingFactorValue = "scaling_factor", - ScalingValue = "scaling_value", - }, - ], - ScalingKey = "scaling_key", - UnitAmounts = - [ - new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, ], + Prorated = true, }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14213,28 +17883,30 @@ 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); } [Fact] - public void GroupedWithMinMaxThresholdsValidationWorks() + public void NewSubscriptionBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + new Subscriptions::NewSubscriptionBulkPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.Annual, - GroupedWithMinMaxThresholdsConfig = new() - { - GroupingKey = "x", - MaximumCharge = "maximum_charge", - MinimumCharge = "minimum_charge", - PerUnitRate = "per_unit_rate", - }, + 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, @@ -14264,35 +17936,38 @@ public void GroupedWithMinMaxThresholdsValidationWorks() 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 NewSubscriptionMatrixWithDisplayNameValidationWorks() + public void BulkWithFiltersSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() + 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,33 +17997,31 @@ public void NewSubscriptionMatrixWithDisplayNameValidationWorks() 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 NewSubscriptionGroupedTieredPackageValidationWorks() + public void NewSubscriptionPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() + new Subscriptions::NewSubscriptionPackagePrice() { - 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::NewSubscriptionPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, Name = "Annual fee", + PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14377,32 +18050,38 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageValidationWorks() + public void NewSubscriptionMatrixSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() + new Subscriptions::NewSubscriptionMatrixPrice() { - Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, ItemID = "item_id", - MaxGroupTieredPackageConfig = new() + MatrixConfig = new() { - GroupingKey = "x", - PackageSize = "package_size", - Tiers = + DefaultUnitAmount = "default_unit_amount", + Dimensions = ["string"], + MatrixValues = [ - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, - new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, + new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, ], }, - ModelType = - Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, + ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14432,39 +18111,39 @@ public void NewSubscriptionMaxGroupTieredPackageValidationWorks() 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 NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() + public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, + Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.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, @@ -14494,42 +18173,38 @@ public void NewSubscriptionScalableMatrixWithUnitPricingValidationWorks() 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 NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() + public void NewSubscriptionTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() + new Subscriptions::NewSubscriptionTieredPackagePrice() { - Cadence = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.ScalableMatrixWithTieredPricing, + ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.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, @@ -14559,36 +18234,51 @@ public void NewSubscriptionScalableMatrixWithTieredPricingValidationWorks() 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 NewSubscriptionCumulativeGroupedBulkValidationWorks() + public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() + new Subscriptions::NewSubscriptionTieredWithMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() + Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.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 = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14617,28 +18307,38 @@ public void NewSubscriptionCumulativeGroupedBulkValidationWorks() 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 CumulativeGroupedAllocationValidationWorks() + public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() + new Subscriptions::NewSubscriptionGroupedTieredPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.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 = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14668,23 +18368,50 @@ public void CumulativeGroupedAllocationValidationWorks() 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 MinimumValidationWorks() + public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence.Annual, + Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, ItemID = "item_id", - MinimumConfig = new() { MinimumAmount = "minimum_amount", Prorated = true }, + 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() @@ -14713,28 +18440,37 @@ public void MinimumValidationWorks() 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 NewSubscriptionMinimumCompositeValidationWorks() + public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + new Subscriptions::NewSubscriptionPackageWithAllocationPrice() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, + Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, Name = "Annual fee", + PackageWithAllocationConfig = new() + { + Allocation = "allocation", + PackageAmount = "package_amount", + PackageSize = "package_size", + }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14763,23 +18499,32 @@ public void NewSubscriptionMinimumCompositeValidationWorks() 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 PercentValidationWorks() + public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + new Subscriptions::NewSubscriptionUnitWithPercentPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, Name = "Annual fee", - PercentConfig = new(0), + UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -14808,27 +18553,40 @@ 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(value, ModelBase.SerializerOptions); + var deserialized = + JsonSerializer.Deserialize( + element, + ModelBase.SerializerOptions + ); + + Assert.Equal(value, deserialized); } [Fact] - public void EventOutputValidationWorks() + public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, - EventOutputConfig = new() + Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.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 = + Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -14858,23 +18616,33 @@ public void EventOutputValidationWorks() 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 NewSubscriptionUnitSerializationRoundtripWorks() + public void TieredWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() { - Cadence = Subscriptions::NewSubscriptionUnitPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.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() @@ -14903,6 +18671,7 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14917,28 +18686,17 @@ public void NewSubscriptionUnitSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredSerializationRoundtripWorks() + public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPrice() + new Subscriptions::NewSubscriptionUnitWithProrationPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPriceModelType.Tiered, + ModelType = + Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.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() @@ -14967,6 +18725,7 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -14981,15 +18740,21 @@ public void NewSubscriptionTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkSerializationRoundtripWorks() + public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkPrice() + new Subscriptions::NewSubscriptionGroupedAllocationPrice() { - BulkConfig = new([new() { UnitAmount = "unit_amount", MaximumUnits = 0 }]), - Cadence = Subscriptions::NewSubscriptionBulkPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, + GroupedAllocationConfig = new() + { + Allocation = "allocation", + GroupingKey = "x", + OverageUnitRate = "overage_unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::ModelType.Bulk, + ModelType = + Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15019,6 +18784,7 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15033,23 +18799,21 @@ public void NewSubscriptionBulkSerializationRoundtripWorks() } [Fact] - public void BulkWithFiltersSerializationRoundtripWorks() + public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + new Subscriptions::NewSubscriptionBulkWithProrationPrice() { - BulkWithFiltersConfig = new() - { - Filters = [new() { PropertyKey = "x", PropertyValue = "x" }], - Tiers = + BulkWithProrationConfig = new( [ new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ], - }, - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ] + ), + Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15079,6 +18843,7 @@ public void BulkWithFiltersSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15093,16 +18858,23 @@ public void BulkWithFiltersSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionPackageSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackagePrice() + new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionPackagePriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, + GroupedWithProratedMinimumConfig = new() + { + GroupingKey = "x", + Minimum = "minimum", + UnitRate = "unit_rate", + }, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionPackagePriceModelType.Package, + ModelType = + Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", - PackageConfig = new() { PackageAmount = "package_amount", PackageSize = 1 }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15131,6 +18903,7 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15145,23 +18918,35 @@ public void NewSubscriptionPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMatrixSerializationRoundtripWorks() + public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixPrice() + new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() { - Cadence = Subscriptions::NewSubscriptionMatrixPriceCadence.Annual, - ItemID = "item_id", - MatrixConfig = new() + Cadence = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceCadence.Annual, + GroupedWithMeteredMinimumConfig = new() { - DefaultUnitAmount = "default_unit_amount", - Dimensions = ["string"], - MatrixValues = + GroupingKey = "x", + MinimumUnitAmount = "minimum_unit_amount", + PricingKey = "pricing_key", + ScalingFactors = [ - new() { DimensionValues = ["string"], UnitAmount = "unit_amount" }, + new() + { + ScalingFactorValue = "scaling_factor", + ScalingValue = "scaling_value", + }, + ], + ScalingKey = "scaling_key", + UnitAmounts = + [ + new() { PricingValue = "pricing_value", UnitAmountValue = "unit_amount" }, ], }, - ModelType = Subscriptions::NewSubscriptionMatrixPriceModelType.Matrix, + ItemID = "item_id", + ModelType = + Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15191,6 +18976,7 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15205,25 +18991,22 @@ public void NewSubscriptionMatrixSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() + public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionThresholdTotalAmountPrice() - { - Cadence = Subscriptions::NewSubscriptionThresholdTotalAmountPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionThresholdTotalAmountPriceModelType.ThresholdTotalAmount, - Name = "Annual fee", - ThresholdTotalAmountConfig = new() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds() + { + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence.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() @@ -15252,6 +19035,7 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15266,24 +19050,29 @@ public void NewSubscriptionThresholdTotalAmountSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageSerializationRoundtripWorks() + public void NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackagePrice() + new Subscriptions::NewSubscriptionMatrixWithDisplayNamePrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackagePriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceCadence.Annual, ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionTieredPackagePriceModelType.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 = + Subscriptions::NewSubscriptionMatrixWithDisplayNamePriceModelType.MatrixWithDisplayName, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15312,6 +19101,7 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15326,36 +19116,26 @@ public void NewSubscriptionTieredPackageSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredWithMinimumPrice() + new Subscriptions::NewSubscriptionGroupedTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionTieredWithMinimumPriceCadence.Annual, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionTieredWithMinimumPriceModelType.TieredWithMinimum, - Name = "Annual fee", - TieredWithMinimumConfig = new() + Cadence = Subscriptions::NewSubscriptionGroupedTieredPackagePriceCadence.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 = + Subscriptions::NewSubscriptionGroupedTieredPackagePriceModelType.GroupedTieredPackage, + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15384,6 +19164,7 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15398,23 +19179,25 @@ public void NewSubscriptionTieredWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() + public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedTieredPrice() + new Subscriptions::NewSubscriptionMaxGroupTieredPackagePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedTieredPriceCadence.Annual, - GroupedTieredConfig = new() + Cadence = Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceCadence.Annual, + ItemID = "item_id", + MaxGroupTieredPackageConfig = new() { GroupingKey = "x", + PackageSize = "package_size", Tiers = [ new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }, ], }, - ItemID = "item_id", - ModelType = Subscriptions::NewSubscriptionGroupedTieredPriceModelType.GroupedTiered, + ModelType = + Subscriptions::NewSubscriptionMaxGroupTieredPackagePriceModelType.MaxGroupTieredPackage, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15444,6 +19227,7 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15458,34 +19242,33 @@ public void NewSubscriptionGroupedTieredSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionTieredPackageWithMinimumPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() { - Cadence = Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionTieredPackageWithMinimumPriceModelType.TieredPackageWithMinimum, + Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.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, @@ -15515,6 +19298,7 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15529,21 +19313,35 @@ public void NewSubscriptionTieredPackageWithMinimumSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() + public void NewSubscriptionScalableMatrixWithTieredPricingSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionPackageWithAllocationPrice() + new Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPrice() { - Cadence = Subscriptions::NewSubscriptionPackageWithAllocationPriceCadence.Annual, + Cadence = + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceCadence.Annual, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionPackageWithAllocationPriceModelType.PackageWithAllocation, + Subscriptions::NewSubscriptionScalableMatrixWithTieredPricingPriceModelType.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, @@ -15573,6 +19371,7 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15587,17 +19386,29 @@ public void NewSubscriptionPackageWithAllocationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() + public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithPercentPrice() + new Subscriptions::NewSubscriptionCumulativeGroupedBulkPrice() { - Cadence = Subscriptions::NewSubscriptionUnitWithPercentPriceCadence.Annual, + Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, + CumulativeGroupedBulkConfig = new() + { + DimensionValues = + [ + new() + { + GroupingKey = "x", + TierLowerBound = "tier_lower_bound", + UnitAmount = "unit_amount", + }, + ], + Group = "group", + }, ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionUnitWithPercentPriceModelType.UnitWithPercent, + Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, Name = "Annual fee", - UnitWithPercentConfig = new() { Percent = "percent", UnitAmount = "unit_amount" }, BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15626,6 +19437,7 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15640,25 +19452,21 @@ public void NewSubscriptionUnitWithPercentSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() + public void CumulativeGroupedAllocationSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMatrixWithAllocationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() { - Cadence = Subscriptions::NewSubscriptionMatrixWithAllocationPriceCadence.Annual, - ItemID = "item_id", - MatrixWithAllocationConfig = new() + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.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 = - Subscriptions::NewSubscriptionMatrixWithAllocationPriceModelType.MatrixWithAllocation, + ItemID = "item_id", Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15688,6 +19496,7 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15702,18 +19511,26 @@ public void NewSubscriptionMatrixWithAllocationSerializationRoundtripWorks() } [Fact] - public void TieredWithProrationSerializationRoundtripWorks() + public void DailyCreditAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance() { Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence.Annual, + 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", - TieredWithProrationConfig = new( - [new() { TierLowerBound = "tier_lower_bound", UnitAmount = "unit_amount" }] - ), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15742,6 +19559,7 @@ public void TieredWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15756,17 +19574,24 @@ public void TieredWithProrationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() + public void MeteredAllowanceSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionUnitWithProrationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance() { - Cadence = Subscriptions::NewSubscriptionUnitWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionUnitWithProrationPriceModelType.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() @@ -15795,6 +19620,7 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15809,21 +19635,20 @@ public void NewSubscriptionUnitWithProrationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() + public void NewSubscriptionMinimumCompositeSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedAllocationPrice() + new Subscriptions::NewSubscriptionMinimumCompositePrice() { - Cadence = Subscriptions::NewSubscriptionGroupedAllocationPriceCadence.Annual, - GroupedAllocationConfig = new() + Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, + ItemID = "item_id", + MinimumCompositeConfig = new() { - Allocation = "allocation", - GroupingKey = "x", - OverageUnitRate = "overage_unit_rate", + MinimumAmount = "minimum_amount", + Prorated = true, }, - ItemID = "item_id", ModelType = - Subscriptions::NewSubscriptionGroupedAllocationPriceModelType.GroupedAllocation, + Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15853,6 +19678,7 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15867,22 +19693,16 @@ public void NewSubscriptionGroupedAllocationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() + public void PercentSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionBulkWithProrationPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() { - BulkWithProrationConfig = new( - [ - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - new() { UnitAmount = "unit_amount", TierLowerBound = "tier_lower_bound" }, - ] - ), - Cadence = Subscriptions::NewSubscriptionBulkWithProrationPriceCadence.Annual, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercentCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionBulkWithProrationPriceModelType.BulkWithProration, Name = "Annual fee", + PercentConfig = new(0), BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -15911,6 +19731,7 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15925,22 +19746,20 @@ public void NewSubscriptionBulkWithProrationSerializationRoundtripWorks() } [Fact] - public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks() + public void EventOutputSerializationRoundtripWorks() { Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithProratedMinimumPrice() + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() { Cadence = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceCadence.Annual, - GroupedWithProratedMinimumConfig = new() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutputCadence.Annual, + EventOutputConfig = new() { - GroupingKey = "x", - Minimum = "minimum", - UnitRate = "unit_rate", + UnitRatingKey = "x", + DefaultUnitRate = "default_unit_rate", + GroupingKey = "grouping_key", }, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithProratedMinimumPriceModelType.GroupedWithProratedMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -15970,6 +19789,7 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -15982,37 +19802,28 @@ public void NewSubscriptionGroupedWithProratedMinimumSerializationRoundtripWorks Assert.Equal(value, deserialized); } +} +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersTest : TestBase +{ [Fact] - public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks() + public void FieldRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPrice() + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters { - 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionGroupedWithMeteredMinimumPriceModelType.GroupedWithMeteredMinimum, Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, @@ -16042,34 +19853,107 @@ public void NewSubscriptionGroupedWithMeteredMinimumSerializationRoundtripWorks( Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + 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 GroupedWithMinMaxThresholdsSerializationRoundtripWorks() + public void SerializationRoundtrip_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", @@ -16100,42 +19984,39 @@ public void GroupedWithMinMaxThresholdsSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); + + 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 NewSubscriptionMatrixWithDisplayNameSerializationRoundtripWorks() + public void FieldRoundtripThroughSerialization_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, @@ -16165,39 +20046,119 @@ 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); + + 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 + > 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); + Assert.Equal(value, deserialized.Metadata[item.Key]); + } + Assert.Equal(expectedReferenceID, deserialized.ReferenceID); } [Fact] - public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() + public void Validation_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, @@ -16227,109 +20188,213 @@ public void NewSubscriptionGroupedTieredPackageSerializationRoundtripWorks() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + model.Validate(); } [Fact] - public void NewSubscriptionMaxGroupTieredPackageSerializationRoundtripWorks() + public void OptionalNullablePropertiesUnsetAreNotSet_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, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() + }; + + Assert.Null(model.BillableMetricID); + Assert.False(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.False(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.False(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.False(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.False(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.False(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.False(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.False(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.False(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.False(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.False(model.RawData.ContainsKey("reference_id")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + { + BulkWithFiltersConfig = new() { - 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_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, }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - Assert.Equal(value, deserialized); + Assert.Null(model.BillableMetricID); + Assert.True(model.RawData.ContainsKey("billable_metric_id")); + Assert.Null(model.BilledInAdvance); + Assert.True(model.RawData.ContainsKey("billed_in_advance")); + Assert.Null(model.BillingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("billing_cycle_configuration")); + Assert.Null(model.ConversionRate); + Assert.True(model.RawData.ContainsKey("conversion_rate")); + Assert.Null(model.ConversionRateConfig); + Assert.True(model.RawData.ContainsKey("conversion_rate_config")); + Assert.Null(model.Currency); + Assert.True(model.RawData.ContainsKey("currency")); + Assert.Null(model.DimensionalPriceConfiguration); + Assert.True(model.RawData.ContainsKey("dimensional_price_configuration")); + Assert.Null(model.ExternalPriceID); + Assert.True(model.RawData.ContainsKey("external_price_id")); + Assert.Null(model.FixedPriceQuantity); + Assert.True(model.RawData.ContainsKey("fixed_price_quantity")); + Assert.Null(model.InvoiceGroupingKey); + Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); + Assert.Null(model.InvoicingCycleConfiguration); + Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(model.LicenseTypeID); + Assert.True(model.RawData.ContainsKey("license_type_id")); + Assert.Null(model.Metadata); + Assert.True(model.RawData.ContainsKey("metadata")); + Assert.Null(model.ReferenceID); + Assert.True(model.RawData.ContainsKey("reference_id")); } [Fact] - public void NewSubscriptionScalableMatrixWithUnitPricingSerializationRoundtripWorks() + public void OptionalNullablePropertiesSetToNullValidation_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPrice() + 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::NewSubscriptionScalableMatrixWithUnitPricingPriceCadence.Annual, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionScalableMatrixWithUnitPricingPriceModelType.ScalableMatrixWithUnitPricing, Name = "Annual fee", - ScalableMatrixWithUnitPricingConfig = new() + + BillableMetricID = null, + BilledInAdvance = null, + BillingCycleConfiguration = null, + ConversionRate = null, + ConversionRateConfig = null, + Currency = null, + DimensionalPriceConfiguration = null, + ExternalPriceID = null, + FixedPriceQuantity = null, + InvoiceGroupingKey = null, + InvoicingCycleConfiguration = null, + LicenseTypeID = null, + Metadata = null, + ReferenceID = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + { + 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", }, + Cadence = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence.Annual, + ItemID = "item_id", + Name = "Annual fee", BillableMetricID = "billable_metric_id", BilledInAdvance = true, BillingCycleConfiguration = new() @@ -16358,368 +20423,564 @@ 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); + + 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 CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + { + PropertyKey = "x", + PropertyValue = "x", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierTest + : TestBase +{ + [Fact] + public void FieldRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + string expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, model.UnitAmount); + Assert.Equal(expectedTierLowerBound, model.TierLowerBound); + } + + [Fact] + public void SerializationRoundtrip_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + 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::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier { - 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", + TierLowerBound = "tier_lower_bound", }; - 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 expectedUnitAmount = "unit_amount"; + string expectedTierLowerBound = "tier_lower_bound"; + + Assert.Equal(expectedUnitAmount, deserialized.UnitAmount); + Assert.Equal(expectedTierLowerBound, deserialized.TierLowerBound); } [Fact] - public void NewSubscriptionCumulativeGroupedBulkSerializationRoundtripWorks() + public void Validation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesUnsetAreNotSet_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + Assert.Null(model.TierLowerBound); + Assert.False(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesUnsetValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + }; + + model.Validate(); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + Assert.Null(model.TierLowerBound); + Assert.True(model.RawData.ContainsKey("tier_lower_bound")); + } + + [Fact] + public void OptionalNullablePropertiesSetToNullValidation_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + + TierLowerBound = null, + }; + + model.Validate(); + } + + [Fact] + public void CopyConstructor_Works() + { + var model = + new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + { + UnitAmount = "unit_amount", + TierLowerBound = "tier_lower_bound", + }; + + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier copied = + new(model); + + Assert.Equal(model, copied); + } +} + +public class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceTest + : 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::NewSubscriptionCumulativeGroupedBulkPrice() - { - Cadence = Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceCadence.Annual, - CumulativeGroupedBulkConfig = new() - { - DimensionValues = - [ - new() - { - GroupingKey = "x", - TierLowerBound = "tier_lower_bound", - UnitAmount = "unit_amount", - }, - ], - Group = "group", - }, - ItemID = "item_id", - ModelType = - Subscriptions::NewSubscriptionCumulativeGroupedBulkPriceModelType.CumulativeGroupedBulk, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); + // 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 CumulativeGroupedAllocationSerializationRoundtripWorks() + public void InvalidEnumSerializationRoundtrip_Works() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation() - { - Cadence = - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence.Annual, - CumulativeGroupedAllocationConfig = new() - { - CumulativeAllocation = "cumulative_allocation", - GroupAllocation = "group_allocation", - GroupingKey = "x", - UnitAmount = "unit_amount", - }, - ItemID = "item_id", - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - 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 MinimumSerializationRoundtripWorks() + public void UnitValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedUnitConversionRateConfig() { - 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", + 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 NewSubscriptionMinimumCompositeSerializationRoundtripWorks() + public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::NewSubscriptionMinimumCompositePrice() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + new SharedTieredConversionRateConfig() { - Cadence = Subscriptions::NewSubscriptionMinimumCompositePriceCadence.Annual, - ItemID = "item_id", - MinimumCompositeConfig = new() - { - MinimumAmount = "minimum_amount", - Prorated = true, - }, - ModelType = - Subscriptions::NewSubscriptionMinimumCompositePriceModelType.MinimumComposite, - Name = "Annual fee", - BillableMetricID = "billable_metric_id", - BilledInAdvance = true, - BillingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - ConversionRate = 0, - ConversionRateConfig = new SharedUnitConversionRateConfig() - { - ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, - UnitConfig = new("unit_amount"), - }, - Currency = "currency", - DimensionalPriceConfiguration = new() - { - DimensionValues = ["string"], - DimensionalPriceGroupID = "dimensional_price_group_id", - ExternalDimensionalPriceGroupID = "external_dimensional_price_group_id", - }, - ExternalPriceID = "external_price_id", - FixedPriceQuantity = 0, - InvoiceGroupingKey = "x", - InvoicingCycleConfiguration = new() - { - Duration = 0, - DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, - }, - Metadata = new Dictionary() { { "foo", "string" } }, - ReferenceID = "reference_id", - }; - string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); - var deserialized = - JsonSerializer.Deserialize( - element, - ModelBase.SerializerOptions - ); - - Assert.Equal(value, deserialized); + ConversionRateType = ConversionRateType.Tiered, + TieredConfig = new( + [ + new() + { + FirstUnit = 0, + UnitAmount = "unit_amount", + LastUnit = 0, + }, + ] + ), + }; + value.Validate(); } [Fact] - public void PercentSerializationRoundtripWorks() + public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePricePercent() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig 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 +20989,26 @@ public void PercentSerializationRoundtripWorks() } [Fact] - public void EventOutputSerializationRoundtripWorks() + public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePrice value = - new Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput() + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig 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 +21017,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 +21060,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 +21083,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -16885,14 +21104,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 +21124,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +21140,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 +21177,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 +21196,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 +21233,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 +21264,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17082,14 +21285,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 +21308,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +21324,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 +21361,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -17173,21 +21373,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 +21406,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +21418,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 +21436,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 +21457,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -17299,6 +21484,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +21496,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 +21517,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 +21734,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 +21900,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17829,7 +21921,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17837,7 +21929,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17848,7 +21940,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -17865,7 +21957,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -17874,21 +21966,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 +22014,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 +22045,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -17960,14 +22066,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 +22089,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +22105,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 +22146,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 +22165,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 +22206,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 +22221,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 +22245,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18137,14 +22266,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 +22292,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +22308,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 +22349,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -18222,15 +22361,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 +22398,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22410,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 +22432,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 +22457,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -18330,6 +22484,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +22496,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 +22521,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 +22626,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -18419,38 +22636,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 +22680,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 +22695,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 +22747,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 +22826,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18681,7 +22847,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18689,7 +22855,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18700,7 +22866,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -18717,7 +22883,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -18726,23 +22892,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 +22940,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 +22971,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -18825,13 +22992,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 +23015,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +23031,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 +23072,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 +23091,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 +23132,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 +23147,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 +23171,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19021,13 +23192,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 +23218,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +23234,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 +23275,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19113,16 +23287,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 +23324,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23336,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 +23358,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 +23383,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -19233,6 +23410,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +23422,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 +23447,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 +23552,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -19326,38 +23562,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 +23606,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 +23621,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 +23673,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 +23752,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19519,7 +23773,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19527,7 +23781,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19538,7 +23792,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -19555,7 +23809,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -19564,23 +23818,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 +23870,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 +23900,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19663,14 +23921,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 +23941,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +23957,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 +24002,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 +24021,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 +24066,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 +24081,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 +24104,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -19859,14 +24125,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 +24148,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +24164,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 +24209,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -19951,16 +24221,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 +24262,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24274,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 +24300,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 +24329,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -20071,6 +24356,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +24368,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 +24397,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 +24506,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20164,38 +24516,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 +24560,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 +24575,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 +24747,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 +24767,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 +24796,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 +24840,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20357,7 +24861,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20365,7 +24869,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20376,7 +24880,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -20393,7 +24897,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -20402,59 +24906,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 +24986,7 @@ public void FieldRoundtrip_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20485,12 +25007,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 +25027,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +25042,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 +25104,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 +25163,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 +25187,7 @@ public void FieldRoundtripThroughSerialization_Works() DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }; double expectedConversionRate = 0; - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig expectedConversionRateConfig = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig expectedConversionRateConfig = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -20656,12 +25208,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 +25231,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +25246,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 +25301,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 +25341,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25352,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 +25376,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 +25431,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +25442,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 +25577,7 @@ public void InvalidEnumValidationThrows_Works() var value = JsonSerializer.Deserialize< ApiEnum< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence > >(JsonSerializer.SerializeToElement("invalid value"), ModelBase.SerializerOptions); @@ -20922,38 +25587,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 +25631,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 +25646,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 +25706,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 +25760,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 +25793,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 +25869,7 @@ public void UnitValidationWorks() [Fact] public void TieredValidationWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21155,7 +25890,7 @@ public void TieredValidationWorks() [Fact] public void UnitSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedUnitConversionRateConfig() { ConversionRateType = SharedUnitConversionRateConfigConversionRateType.Unit, @@ -21163,7 +25898,7 @@ public void UnitSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21174,7 +25909,7 @@ public void UnitSerializationRoundtripWorks() [Fact] public void TieredSerializationRoundtripWorks() { - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value = + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value = new SharedTieredConversionRateConfig() { ConversionRateType = ConversionRateType.Tiered, @@ -21191,7 +25926,7 @@ public void TieredSerializationRoundtripWorks() }; string element = JsonSerializer.Serialize(value, ModelBase.SerializerOptions); var deserialized = - JsonSerializer.Deserialize( + JsonSerializer.Deserialize( element, ModelBase.SerializerOptions ); @@ -21240,6 +25975,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21283,6 +26019,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 +26039,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26089,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21403,6 +26142,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21454,6 +26194,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 +26217,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +26267,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -21566,6 +26309,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26354,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -21635,6 +26381,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +26411,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 +26647,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 +26794,7 @@ public void FieldRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22028,6 +26843,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 +26863,7 @@ public void FieldRoundtrip_Works() Assert.Equal(expectedFixedPriceQuantity, model.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, model.InvoiceGroupingKey); Assert.Equal(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 +26919,7 @@ public void SerializationRoundtrip_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22160,6 +26978,7 @@ public void FieldRoundtripThroughSerialization_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22216,6 +27035,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 +27058,7 @@ public void FieldRoundtripThroughSerialization_Works() Assert.Equal(expectedFixedPriceQuantity, deserialized.FixedPriceQuantity); Assert.Equal(expectedInvoiceGroupingKey, deserialized.InvoiceGroupingKey); Assert.Equal(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 +27114,7 @@ public void Validation_Works() Duration = 0, DurationUnit = NewBillingCycleConfigurationDurationUnit.Day, }, + LicenseTypeID = "license_type_id", Metadata = new Dictionary() { { "foo", "string" } }, ReferenceID = "reference_id", }; @@ -22340,6 +27162,8 @@ public void OptionalNullablePropertiesUnsetAreNotSet_Works() Assert.False(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.False(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27219,7 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() FixedPriceQuantity = null, InvoiceGroupingKey = null, InvoicingCycleConfiguration = null, + LicenseTypeID = null, Metadata = null, ReferenceID = null, }; @@ -22421,6 +27246,8 @@ public void OptionalNullablePropertiesSetToNullAreSetToNull_Works() Assert.True(model.RawData.ContainsKey("invoice_grouping_key")); Assert.Null(model.InvoicingCycleConfiguration); Assert.True(model.RawData.ContainsKey("invoicing_cycle_configuration")); + Assert.Null(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 +27282,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 +27599,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..84d18a2a9 100644 --- a/src/Orb/Core/ModelBase.cs +++ b/src/Orb/Core/ModelBase.cs @@ -15,6 +15,7 @@ using ExternalPlanID = Orb.Models.Beta.ExternalPlanID; using Invoices = Orb.Models.Invoices; using Ledger = Orb.Models.Customers.Credits.Ledger; +using Licenses = Orb.Models.Licenses; using Metrics = Orb.Models.Metrics; using Migrations = Orb.Models.Plans.Migrations; using Plans = Orb.Models.Plans; @@ -398,11 +399,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,12 +438,17 @@ 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< @@ -448,16 +459,28 @@ 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< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceCadence + >(), + new ApiEnumConverter< + string, + ExternalPlanID::ReplacePriceLicenseAllocationPriceModelType + >(), new ApiEnumConverter(), new ApiEnumConverter< string, @@ -471,7 +494,14 @@ 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(), @@ -569,6 +599,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 +632,6 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -596,10 +639,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(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -620,13 +666,15 @@ 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< @@ -643,7 +691,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Prices::PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -825,7 +877,8 @@ protected ModelBase(ModelBase modelBase) new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), - new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -842,7 +895,11 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::ReplacePricePriceCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), + new ApiEnumConverter< + string, + Subscriptions::ReplacePricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -859,7 +916,8 @@ protected ModelBase(ModelBase modelBase) string, Subscriptions::PriceModelCumulativeGroupedAllocationCadence >(), - new ApiEnumConverter(), + new ApiEnumConverter(), + new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), new ApiEnumConverter(), @@ -885,7 +943,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -914,7 +976,11 @@ protected ModelBase(ModelBase modelBase) >(), new ApiEnumConverter< string, - Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumCadence + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence + >(), + new ApiEnumConverter< + string, + Subscriptions::SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceCadence >(), new ApiEnumConverter< string, @@ -930,9 +996,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 +1024,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..2fa166483 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,2739 +962,7025 @@ 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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(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. - /// - /// 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.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. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// 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. /// /// /// - /// 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `BulkWithFilters` + /// 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 TryPickBulkWithFilters([NotNullWhen(true)] out BulkWithFilters? 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 BulkWithFilters; + return value != null; } - public static implicit operator global::Orb.Models.Beta.Price(NewPlanUnitPrice value) => - new(value); - - public static implicit operator global::Orb.Models.Beta.Price(NewPlanTieredPrice value) => - new(value); + /// + /// Returns true and sets the 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; + } - public static implicit operator global::Orb.Models.Beta.Price(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.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( - 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.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 "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.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 "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.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 "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.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 "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.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 "tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( + /// + /// Returns true and sets the 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) => {...}, + /// (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 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 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"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was 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) => {...}, + /// (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 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), + 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"), + }; + } + + public static implicit operator Price(NewPlanUnitPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkPrice value) => new(value); + + public static implicit operator Price(BulkWithFilters value) => new(value); + + public static implicit operator Price(NewPlanPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + + public static implicit operator Price(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); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException("Data did not match any variant of Price"); + } + this.Switch( + (newPlanUnit) => newPlanUnit.Validate(), + (newPlanTiered) => newPlanTiered.Validate(), + (newPlanBulk) => newPlanBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newPlanPackage) => newPlanPackage.Validate(), + (newPlanMatrix) => newPlanMatrix.Validate(), + (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), + (newPlanTieredPackage) => newPlanTieredPackage.Validate(), + (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), + (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), + (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), + (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), + (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), + (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), + (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), + (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), + (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), + (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), + (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), + (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), + (newPlanScalableMatrixWithUnitPricing) => + newPlanScalableMatrixWithUnitPricing.Validate(), + (newPlanScalableMatrixWithTieredPricing) => + newPlanScalableMatrixWithTieredPricing.Validate(), + (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + NewPlanMinimumCompositePrice _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -1, + }; + } +} + +sealed class PriceConverter : JsonConverter +{ + public override Price? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } + + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "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 Price(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new BulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" + ); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Configuration for tiered_with_proration pricing + /// + public required TieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithProrationConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithProrationConfig.Validate(); + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 + + public TieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationFromRaw : IFromRawJson +{ + /// + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : JsonModel +{ + /// + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationConfigFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithProrationConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new TieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMinMaxThresholds : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); + } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholds(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholds FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] +public enum GroupedWithMinMaxThresholdsCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class GroupedWithMinMaxThresholdsCadenceConverter + : JsonConverter +{ + public override GroupedWithMinMaxThresholdsCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + GroupedWithMinMaxThresholdsCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for grouped_with_min_max_thresholds pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +{ + /// + /// The event property used to group before applying thresholds + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The maximum amount to charge each group + /// + public required string MaximumCharge + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("maximum_charge"); + } + init { this._rawData.Set("maximum_charge", value); } + } + + /// + /// The minimum amount to charge each group, regardless of usage + /// + public required string MinimumCharge + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("minimum_charge"); + } + init { this._rawData.Set("minimum_charge", value); } + } + + /// + /// The base price charged per group + /// + public required string PerUnitRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("per_unit_rate"); + } + init { this._rawData.Set("per_unit_rate", value); } + } + + /// + public override void Validate() + { + _ = this.GroupingKey; + _ = this.MaximumCharge; + _ = this.MinimumCharge; + _ = this.PerUnitRate; + } + + public GroupedWithMinMaxThresholdsConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsConfig( + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + ) + : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(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) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } - return new(element); - } - case "tiered_with_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); + } + 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); } + } + + /// + /// The id of the item the price will 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 CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } - 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.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - return new(element); - } - case "tiered_package_with_minimum": + public CumulativeGroupedAllocation() + { + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocation(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocation FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for cumulative_grouped_allocation pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationConfig : JsonModel +{ + /// + /// The overall allocation across all groups + /// + public required string CumulativeAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("cumulative_allocation"); + } + init { this._rawData.Set("cumulative_allocation", value); } + } + + /// + /// The allocation per individual group + /// + public required string GroupAllocation + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } + } + + /// + /// The event property used to group usage before applying allocations + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The amount to charge for each unit outside of the allocation + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; + _ = this.UnitAmount; + } + + public CumulativeGroupedAllocationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - 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 CumulativeGroupedAllocationConfig(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] + CumulativeGroupedAllocationConfig(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 CumulativeGroupedAllocationConfig 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 CumulativeGroupedAllocationConfigFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedAllocationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationConfig.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(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : 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 CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + ); + } + } - 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 and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + ), + }; + } - 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 CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig( + 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 CumulativeGroupedAllocationConversionRateConfig" + ); + } + 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(CumulativeGroupedAllocationConversionRateConfig? 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 + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - 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 - } +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } - return new(element); - } - case "minimum_composite": + 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 } @@ -3635,57 +7989,52 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.Price(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.Price? value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFilters, - global::Orb.Models.Beta.BulkWithFiltersFromRaw - >) -)] -public sealed record class BulkWithFilters : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : JsonModel { /// - /// Configuration for bulk_with_filters pricing + /// The cadence to bill for this price on. /// - public required global::Orb.Models.Beta.BulkWithFiltersConfig BulkWithFiltersConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" + return this._rawData.GetNotNullClass>( + "cadence" ); } - init { this._rawData.Set("bulk_with_filters_config", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The cadence to bill for this price on. + /// Configuration for daily_credit_allowance pricing /// - public required ApiEnum Cadence + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass>( - "cadence" + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" ); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// @@ -3786,12 +8135,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ConversionRateConfig? ConversionRateConfig + public DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -3882,6 +8231,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -3920,13 +8282,13 @@ public string? ReferenceID /// public override void Validate() { - this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { @@ -3944,35 +8306,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public BulkWithFilters(global::Orb.Models.Beta.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -3980,181 +8346,196 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.BulkWithFilters FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFilters.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter +{ + public override DailyCreditAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + DailyCreditAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.BulkWithFiltersConfig, - global::Orb.Models.Beta.BulkWithFiltersConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class BulkWithFiltersConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// Property filters to apply (all must match) + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required IReadOnlyList Filters + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "filters" - ); - } - init - { - this._rawData.Set>( - "filters", - ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("daily_allowance"); } + init { this._rawData.Set("daily_allowance", value); } } /// - /// Bulk tiers for rating based on total usage volume + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public required IReadOnlyList Tiers + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct>( - "tiers" - ); - } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("default_unit_amount"); } + init { this._rawData.Set("default_unit_amount", value); } } - /// - public override void Validate() + /// + /// One or two event property values to evaluate matrix groups by + /// + public required IReadOnlyList Dimensions { - foreach (var item in this.Filters) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("dimensions"); } - foreach (var item in this.Tiers) + init { - item.Validate(); + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); } } - public BulkWithFiltersConfig() { } - - public BulkWithFiltersConfig( - global::Orb.Models.Beta.BulkWithFiltersConfig bulkWithFiltersConfig - ) - : base(bulkWithFiltersConfig) { } - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class BulkWithFiltersConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - -/// -/// Configuration for a single property filter -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Filter, - global::Orb.Models.Beta.FilterFromRaw - >) -)] -public sealed record class Filter : JsonModel -{ /// - /// Event property key to filter on + /// 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 PropertyKey + public required string EventDayProperty { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullClass("event_day_property"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("event_day_property", value); } } /// - /// Event property value to match + /// Per-dimension credit rates /// - public required string PropertyValue + public required IReadOnlyList MatrixValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); + return this._rawData.GetNotNullStruct>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("property_value", value); } } /// public override void Validate() { - _ = this.PropertyKey; - _ = this.PropertyValue; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public Filter() { } + public DailyCreditAllowanceConfig() { } - public Filter(global::Orb.Models.Beta.Filter filter) - : base(filter) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public Filter(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Filter(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Filter FromRawUnchecked( + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4162,158 +8543,97 @@ IReadOnlyDictionary rawData } } -class FilterFromRaw : IFromRawJson +class DailyCreditAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Filter FromRawUnchecked( + public DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Filter.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single bulk pricing tier +/// Per-dimension credit price for the daily credit allowance model. /// -[JsonConverter( - typeof(JsonModelConverter) -)] -public sealed record class Tier : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MatrixValue : JsonModel { /// - /// Amount per unit + /// 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 UnitAmount + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("unit_amount", value); } } /// - /// The lower bound for this tier + /// Credits charged per unit of usage matching the specified dimension_values /// - 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.DimensionValues; _ = this.UnitAmount; - _ = this.TierLowerBound; } - public Tier() { } + public MatrixValue() { } - public Tier(global::Orb.Models.Beta.Tier tier) - : base(tier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 - public Tier(IReadOnlyDictionary rawData) + public MatrixValue(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + MatrixValue(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class TierFromRaw : IFromRawJson +class MatrixValueFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Beta.Cadence.Annual, - "semi_annual" => global::Orb.Models.Beta.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.Cadence.Monthly, - "quarterly" => global::Orb.Models.Beta.Cadence.Quarterly, - "one_time" => global::Orb.Models.Beta.Cadence.OneTime, - "custom" => global::Orb.Models.Beta.Cadence.Custom, - _ => (global::Orb.Models.Beta.Cadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.Cadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.Cadence.Annual => "annual", - global::Orb.Models.Beta.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.Cadence.Monthly => "monthly", - global::Orb.Models.Beta.Cadence.Quarterly => "quarterly", - global::Orb.Models.Beta.Cadence.OneTime => "one_time", - global::Orb.Models.Beta.Cadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4330,19 +8650,25 @@ public JsonElement Json } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + public DailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + public DailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -4351,7 +8677,7 @@ public ConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4372,7 +8698,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4392,7 +8718,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4403,8 +8729,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4424,7 +8750,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -4433,7 +8759,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4444,8 +8770,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4460,16 +8786,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4488,16 +8814,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 DailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4505,13 +8831,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4540,12 +8879,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4562,12 +8899,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4576,14 +8911,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -4591,25 +8926,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProration, - global::Orb.Models.Beta.TieredWithProrationFromRaw - >) -)] -public sealed record class TieredWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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); } } @@ -4628,44 +8958,44 @@ public required string ItemID } /// - /// The pricing model type + /// Configuration for metered_allowance pricing /// - public JsonElement ModelType + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("metered_allowance_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.Beta.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); } } /// @@ -4727,12 +9057,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? ConversionRateConfig + public MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4823,6 +9153,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4863,17 +9206,17 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("metered_allowance") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -4885,35 +9228,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public TieredWithProration(global::Orb.Models.Beta.TieredWithProration tieredWithProration) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4921,19 +9268,18 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProration.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -4943,10 +9289,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4954,19 +9299,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Beta.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Beta.TieredWithProrationCadence)(-1), + "annual" => 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.Beta.TieredWithProrationCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -4974,12 +9319,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Beta.TieredWithProrationCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Beta.TieredWithProrationCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Beta.TieredWithProrationCadence.Custom => "custom", + 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)) ), @@ -4990,159 +9335,144 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfig, - global::Orb.Models.Beta.TieredWithProrationConfigFromRaw - >) -)] -public sealed record class TieredWithProrationConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// 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 IReadOnlyList Tiers + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + return this._rawData.GetNotNullClass("allowance_grouping_value"); } + init { this._rawData.Set("allowance_grouping_value", value); } } - /// - public override void Validate() + /// + /// The grouping_key value whose summed quantity represents consumption (e.g. + /// 'download'). Charged at unit_amount. + /// + public required string ConsumptionGroupingValue { - foreach (var item in this.Tiers) + get { - item.Validate(); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("consumption_grouping_value"); } + init { this._rawData.Set("consumption_grouping_value", value); } } - public TieredWithProrationConfig() { } - - public TieredWithProrationConfig( - global::Orb.Models.Beta.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } - - public TieredWithProrationConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// 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 { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } } - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) - : this() + /// + /// Per-unit price applied to gross consumption and to the allowance credit. + /// + public required string UnitAmount { - this.Tiers = tiers; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } } -} - -class TieredWithProrationConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfig.FromRawUnchecked(rawData); -} -/// -/// Configuration for a single tiered with proration tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.TieredWithProrationConfigTier, - global::Orb.Models.Beta.TieredWithProrationConfigTierFromRaw - >) -)] -public sealed record class TieredWithProrationConfigTier : JsonModel -{ /// - /// Inclusive tier starting value + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string TierLowerBound + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("tier_lower_bound", value); } } /// - /// Amount per unit + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public required string UnitAmount + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); } - init { this._rawData.Set("unit_amount", value); } } /// public override void Validate() { - _ = this.TierLowerBound; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public TieredWithProrationConfigTier() { } - - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.TieredWithProrationConfigTier tieredWithProrationConfigTier - ) - : base(tieredWithProrationConfigTier) { } - - public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + 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] - TieredWithProrationConfigTier(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5150,17 +9480,16 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.TieredWithProrationConfigTier FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.TieredWithProrationConversionRateConfigConverter))] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5177,7 +9506,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5186,7 +9515,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5195,7 +9524,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5204,7 +9533,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 +9554,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9574,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9585,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5277,7 +9606,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -5286,7 +9615,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9626,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5313,16 +9642,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.TieredWithProrationConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5341,18 +9670,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 MeteredAllowanceConversionRateConfig" ); } 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5360,13 +9687,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.TieredWithProrationConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5395,12 +9735,10 @@ JsonSerializerOptions 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 +9755,10 @@ JsonSerializerOptions 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 +9767,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.TieredWithProrationConversionRateConfig(element); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.TieredWithProrationConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -5446,47 +9782,22 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Percent : 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 - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for grouped_with_min_max_thresholds pricing - /// - public required global::Orb.Models.Beta.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. /// @@ -5526,6 +9837,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -5585,12 +9909,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5681,6 +10005,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,18 +10057,13 @@ 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") - ) - ) + 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(); @@ -5743,58 +10075,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadenceConverter))] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -5804,10 +10134,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5815,19 +10144,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" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -5835,13 +10164,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", + 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)) ), @@ -5852,119 +10180,74 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfigFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : 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 + /// What percent of the component subtotals to charge /// - public required string PerUnitRate + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNotNullStruct("percent"); } - init { this._rawData.Set("per_unit_rate", value); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.Percent; } - public GroupedWithMinMaxThresholdsConfig() { } + public PercentConfig() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public PercentConfig(double percent) + : this() + { + this.Percent = percent; + } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5981,7 +10264,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5990,7 +10273,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5999,7 +10282,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -6008,7 +10291,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 +10312,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10332,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10343,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6081,7 +10364,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -6090,7 +10373,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10384,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6117,16 +10400,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 PercentConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6145,18 +10428,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 PercentConversionRateConfig" ); } 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6164,13 +10445,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } -sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6199,12 +10492,10 @@ JsonSerializerOptions 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 +10512,10 @@ JsonSerializerOptions 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 +10524,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.GroupedWithMinMaxThresholdsConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -6252,45 +10539,33 @@ 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 EventOutput : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for cumulative_grouped_allocation pricing + /// Configuration for event_output pricing /// - public required global::Orb.Models.Beta.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "cumulative_grouped_allocation_config" - ); + return this._rawData.GetNotNullClass("event_output_config"); } - init { this._rawData.Set("cumulative_grouped_allocation_config", value); } + init { this._rawData.Set("event_output_config", value); } } /// @@ -6391,12 +10666,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 EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6487,6 +10762,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,12 +10814,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.CumulativeGroupedAllocationConfig.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("cumulative_grouped_allocation") + JsonSerializer.SerializeToElement("event_output") ) ) { @@ -6549,58 +10837,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationCadenceConverter))] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -6610,10 +10896,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.CumulativeGroupedAllocationCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6621,19 +10906,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" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -6641,13 +10926,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", + 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)) ), @@ -6658,119 +10942,107 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.CumulativeGroupedAllocationConfigFromRaw - >) -)] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// The overall allocation across all groups + /// The key in the event data to extract the unit rate from. /// - public required string CumulativeAllocation + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("cumulative_allocation", value); } + init { this._rawData.Set("unit_rating_key", value); } } /// - /// The allocation per individual group + /// 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 required string GroupAllocation + public string? DefaultUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); + return this._rawData.GetNullableClass("default_unit_rate"); } - init { this._rawData.Set("group_allocation", value); } + init { this._rawData.Set("default_unit_rate", value); } } /// - /// The event property used to group usage before applying allocations + /// 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 required string GroupingKey + public string? GroupingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNullableClass("grouping_key"); } init { this._rawData.Set("grouping_key", value); } } - /// - /// The amount to charge for each unit outside of the allocation - /// - public required string UnitAmount - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); - } - init { this._rawData.Set("unit_amount", value); } - } - /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; _ = this.GroupingKey; - _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public EventOutputConfig() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig - ) - : base(cumulativeGroupedAllocationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public EventOutputConfig(string unitRatingKey) + : this() + { + this.UnitRatingKey = unitRatingKey; + } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.CumulativeGroupedAllocationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6787,7 +11059,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6796,7 +11068,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6805,7 +11077,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -6814,7 +11086,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 +11107,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +11127,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +11138,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6887,7 +11159,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -6896,7 +11168,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11179,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6923,16 +11195,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 EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6951,18 +11223,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 EventOutputConversionRateConfig" ); } 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(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6970,580 +11240,351 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); -sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + int VariantIndex() { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } - - switch (conversionRateType) + return this.Value switch { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - 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.CumulativeGroupedAllocationConversionRateConfig( - element - ); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.CumulativeGroupedAllocationConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Minimum, - global::Orb.Models.Beta.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass>("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// Configuration for minimum pricing - /// - public required global::Orb.Models.Beta.MinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "minimum_config" - ); - } - init { this._rawData.Set("minimum_config", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance + public override EventOutputConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; } - init { this._rawData.Set("billed_in_advance", value); } - } - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get + switch (conversionRateType) { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + 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); + } } - init { this._rawData.Set("billing_cycle_configuration", value); } } - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate + public override void Write( + Utf8JsonWriter writer, + EventOutputConversionRateConfig value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ /// - /// The configuration for the rate of the price currency to the invoicing currency. + /// The id of the adjustment to remove from on the plan. /// - public MinimumConversionRateConfig? ConversionRateConfig + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("conversion_rate_config", value); } + init { this._rawData.Set("adjustment_id", value); } } /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. + /// The phase to remove this adjustment from. /// - public string? Currency + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("currency", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// An alias for the price. - /// - public string? ExternalPriceID + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this._rawData = new(rawData); } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + this.AdjustmentID = adjustmentID; } +} + +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// User-specified key/value pairs for the resource. 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 price to remove from the plan. /// - public IReadOnlyDictionary? Metadata + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + return this._rawData.GetNotNullClass("price_id"); } + init { this._rawData.Set("price_id", value); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// The phase to remove this price from. /// - public string? ReferenceID + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("reference_id", value); } + init { this._rawData.Set("plan_phase_order", value); } } /// public override void Validate() { - this.Cadence.Validate(); - _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + _ = this.PriceID; + _ = this.PlanPhaseOrder; } - public Minimum() - { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); - } + public RemovePrice() { } - public Minimum(global::Orb.Models.Beta.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public RemovePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("minimum"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + RemovePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } -} -class MinimumFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Minimum.FromRawUnchecked(rawData); + [SetsRequiredMembers] + public RemovePrice(string priceID) + : this() + { + this.PriceID = priceID; + } } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +class RemovePriceFromRaw : IFromRawJson { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); } -sealed class MinimumCadenceConverter : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel { - public override MinimumCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The definition of a new adjustment to create and add to the plan. + /// + public required ReplaceAdjustmentAdjustment Adjustment { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "annual" => MinimumCadence.Annual, - "semi_annual" => MinimumCadence.SemiAnnual, - "monthly" => MinimumCadence.Monthly, - "quarterly" => MinimumCadence.Quarterly, - "one_time" => MinimumCadence.OneTime, - "custom" => MinimumCadence.Custom, - _ => (MinimumCadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - MinimumCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - MinimumCadence.Annual => "annual", - MinimumCadence.SemiAnnual => "semi_annual", - MinimumCadence.Monthly => "monthly", - MinimumCadence.Quarterly => "quarterly", - MinimumCadence.OneTime => "one_time", - MinimumCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment"); + } + init { this._rawData.Set("adjustment", value); } } -} -/// -/// Configuration for minimum pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.MinimumConfig, - global::Orb.Models.Beta.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel -{ /// - /// The minimum amount to apply + /// The id of the adjustment on the plan to replace in the plan. /// - public required string MinimumAmount + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// The phase to replace this adjustment from. /// - public bool? Prorated + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); - } - init - { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + return this._rawData.GetNullableStruct("plan_phase_order"); } + init { this._rawData.Set("plan_phase_order", value); } } /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - public MinimumConfig() { } + public ReplaceAdjustment() { } - public MinimumConfig(global::Orb.Models.Beta.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() - { - this.MinimumAmount = minimumAmount; - } } -class MinimumConfigFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.MinimumConfig.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +/// +/// 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; @@ -7560,75 +11601,178 @@ public JsonElement Json } } - public MinimumConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + 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 MinimumConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + 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 MinimumConversionRateConfig(JsonElement element) + public ReplaceAdjustmentAdjustment(JsonElement element) { this._element = element; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewPercentageDiscount; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewUsageDiscount; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + { + value = this.Value as NewAmountDiscount; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + { + value = this.Value as NewMinimum; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + { + value = this.Value as NewMaximum; return value != null; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -7639,28 +11783,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -7669,7 +11828,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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,34 +11839,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator MinimumConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator MinimumConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -7724,16 +11897,22 @@ 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 ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals(MinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7741,5171 +11920,4984 @@ public override int GetHashCode() } 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 MinimumConversionRateConfigConverter : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - default: + case "amount_discount": { - return new MinimumConversionRateConfig(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - MinimumConversionRateConfig value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize(writer, value.Json, options); - } -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.Percent, - global::Orb.Models.Beta.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel -{ - /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.Beta.PercentConfig PercentConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "percent_config" - ); - } - init { this._rawData.Set("percent_config", value); } - } - - /// - /// The id of the billable metric for the price. Only needed if the price is usage-based. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If the Price represents a fixed cost, the price will be billed in-advance - /// if this is true, and in-arrears if this is false. - /// - public bool? BilledInAdvance - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); - } - init { this._rawData.Set("billed_in_advance", value); } - } - - /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. - /// - public NewBillingCycleConfiguration? BillingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); - } - init { this._rawData.Set("billing_cycle_configuration", value); } - } - - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate - { - get - { - this._rawData.Freeze(); - return this._rawData.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.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); } - } + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } - } + return new(element); + } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// An alias for the price. - /// - public string? ExternalPriceID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + 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); + } } - init { this._rawData.Set("external_price_id", value); } } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + public override void Write( + Utf8JsonWriter writer, + ReplaceAdjustmentAdjustment value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + JsonSerializer.Serialize(writer, value.Json, options); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel +{ /// - /// The property used to group this price on an invoice + /// The id of the price on the plan to replace in the plan. /// - public string? InvoiceGroupingKey + public required string ReplacesPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); + return this._rawData.GetNotNullClass("replaces_price_id"); } - init { this._rawData.Set("invoice_grouping_key", value); } + init { this._rawData.Set("replaces_price_id", value); } } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// The allocation price to add to the plan. /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public NewAllocationPrice? AllocationPrice { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); + return this._rawData.GetNullableClass("allocation_price"); } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + init { this._rawData.Set("allocation_price", value); } } /// - /// User-specified key/value pairs for the resource. 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 license allocation price to add to the plan. /// - public IReadOnlyDictionary? Metadata + public ReplacePriceLicenseAllocationPrice? LicenseAllocationPrice { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + return this._rawData.GetNullableClass( + "license_allocation_price" ); } + init { this._rawData.Set("license_allocation_price", value); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// The phase to replace this price from. /// - public string? ReferenceID + public long? PlanPhaseOrder { get { this._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"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - _ = this.Name; - this.PercentConfig.Validate(); - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; - } - - public Percent() - { - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - - public Percent(global::Orb.Models.Beta.Percent percent) - : base(percent) { } - - public Percent(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Percent(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } -} - -class PercentFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.Percent.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.PercentCadenceConverter))] -public enum PercentCadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class PercentCadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.PercentCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - 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), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentCadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + init { this._rawData.Set("plan_phase_order", value); } } -} -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.PercentConfig, - global::Orb.Models.Beta.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel -{ /// - /// What percent of the component subtotals to charge + /// New plan price request body params. /// - public required double Percent + public ReplacePricePrice? Price { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNullableClass("price"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("price", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + this.LicenseAllocationPrice?.Validate(); + _ = this.PlanPhaseOrder; + this.Price?.Validate(); } - public PercentConfig() { } + public ReplacePrice() { } - public PercentConfig(global::Orb.Models.Beta.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public ReplacePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + ReplacePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public PercentConfig(double percent) + public ReplacePrice(string replacesPriceID) : this() { - this.Percent = percent; + this.ReplacesPriceID = replacesPriceID; } } -class PercentConfigFromRaw : IFromRawJson +class ReplacePriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.PercentConfig.FromRawUnchecked(rawData); + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +/// +/// The license allocation price to add to the plan. +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePriceLicenseAllocationPrice, + ReplacePriceLicenseAllocationPriceFromRaw + >) +)] +public sealed record class ReplacePriceLicenseAllocationPrice : 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< + ApiEnum + >("cadence"); } - } - - 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; + 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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public required string ItemID { - value = this.Value as SharedUnitConversionRateConfig; - 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.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public required IReadOnlyList LicenseAllocations { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(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) => {...} - /// ); - /// - /// + /// The pricing model type /// - public void Switch( - System::Action unit, - System::Action tiered - ) + public required ApiEnum ModelType { - 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 PercentConversionRateConfig" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("model_type"); } + init { this._rawData.Set("model_type", 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 name of the price. /// - public T Match( - System::Func unit, - System::Func tiered - ) + public required string Name { - return this.Value switch + get { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" - ), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } } - public static implicit operator global::Orb.Models.Beta.PercentConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.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. - /// + /// Configuration for unit pricing /// - public override void Validate() + public required UnitConfig UnitConfig { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + init { this._rawData.Set("unit_config", value); } } - public virtual bool Equals(global::Orb.Models.Beta.PercentConversionRateConfig? other) + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } - public override int GetHashCode() + /// + /// If the Price represents 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 0; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class PercentConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.PercentConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch + get { - conversionRateType = null; + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } + init { this._rawData.Set("billing_cycle_configuration", value); } + } - switch (conversionRateType) + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + 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.PercentConversionRateConfig(element); - } + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); } + init { this._rawData.Set("conversion_rate", value); } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.PercentConversionRateConfig value, - JsonSerializerOptions options - ) + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public ReplacePriceLicenseAllocationPriceConversionRateConfig? ConversionRateConfig { - JsonSerializer.Serialize(writer, value.Json, options); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutput, - global::Orb.Models.Beta.EventOutputFromRaw - >) -)] -public sealed record class EventOutput : 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 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); } } /// - /// Configuration for event_output pricing + /// For dimensional price: specifies a price group and dimension values /// - public required global::Orb.Models.Beta.EventOutputConfig EventOutputConfig + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" + return this._rawData.GetNullableClass( + "dimensional_price_configuration" ); } - init { this._rawData.Set("event_output_config", 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); } } /// - /// 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 + public string? ReferenceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); + return this._rawData.GetNullableClass("reference_id"); } - init { this._rawData.Set("conversion_rate", value); } + 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 configuration for the rate of the price currency to the invoicing currency. + /// The amount of credits granted per active license per cadence. /// - public global::Orb.Models.Beta.EventOutputConversionRateConfig? ConversionRateConfig + public required string Amount { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); + return this._rawData.GetNotNullClass("amount"); } - init { this._rawData.Set("conversion_rate_config", value); } + init { this._rawData.Set("amount", value); } } /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. + /// The currency of the license allocation. /// - public string? Currency + public required string Currency { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); + return this._rawData.GetNotNullClass("currency"); } init { this._rawData.Set("currency", value); } } /// - /// For dimensional price: specifies a price group and dimension values + /// When True, overage beyond the allocation is written off. /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public bool? WriteOffOverage { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); + return this._rawData.GetNullableStruct("write_off_overage"); } - init { this._rawData.Set("dimensional_price_configuration", value); } + init { this._rawData.Set("write_off_overage", value); } } - /// - /// An alias for the price. - /// - public string? ExternalPriceID + /// + public override void Validate() { - get + _ = 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 { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + "unit" => ReplacePriceLicenseAllocationPriceModelType.Unit, + _ => (ReplacePriceLicenseAllocationPriceModelType)(-1), + }; } - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + 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 { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); } - init { this._rawData.Set("fixed_price_quantity", value); } + } + + 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; } /// - /// The property used to group this price on an invoice + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// /// - public string? InvoiceGroupingKey + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + value = this.Value as SharedUnitConversionRateConfig; + return value != null; } /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } + value = this.Value as SharedTieredConversionRateConfig; + return value != null; } /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// /// - public IReadOnlyDictionary? Metadata + public void Switch( + System::Action unit, + System::Action tiered + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init + switch (this.Value) { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(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" + ); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// /// - public string? ReferenceID + public T Match( + System::Func unit, + System::Func tiered + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); - } - init { this._rawData.Set("reference_id", value); } + 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() { - this.Cadence.Validate(); - this.EventOutputConfig.Validate(); - _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + if (this.Value == null) { - throw new OrbInvalidDataException("Invalid value given for constant"); + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); } - _ = this.Name; - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public EventOutput() + public virtual bool Equals(ReplacePriceLicenseAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + return 0; } - public EventOutput(global::Orb.Models.Beta.EventOutput eventOutput) - : base(eventOutput) { } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - public EventOutput(IReadOnlyDictionary rawData) + int VariantIndex() { - this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) +sealed class ReplacePriceLicenseAllocationPriceConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this._rawData = new(rawData); + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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); + } + } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceConversionRateConfig value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize(writer, value.Json, options); } } -class EventOutputFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutput.FromRawUnchecked(rawData); -} - /// -/// The cadence to bill for this price on. +/// New plan price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} + public object? Value { get; } = null; -sealed class EventOutputCadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.EventOutputCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + JsonElement? _element = null; + + public JsonElement Json { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "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), - }; + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputCadence value, - JsonSerializerOptions options - ) + public string ItemID { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.EventOutputCadence.Annual => "annual", - global::Orb.Models.Beta.EventOutputCadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Beta.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Beta.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + 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, + 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, + 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 + ); + } } -} -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.EventOutputConfig, - global::Orb.Models.Beta.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ - /// - /// The key in the event data to extract the unit rate from. - /// - public required string UnitRatingKey + public string? BillableMetricID { get { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); + 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, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newPlanMinimumComposite: (x) => x.BillableMetricID, + percent: (x) => x.BillableMetricID, + eventOutput: (x) => x.BillableMetricID + ); } - init { this._rawData.Set("unit_rating_key", value); } } - /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. - /// - public string? DefaultUnitRate + public bool? BilledInAdvance { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + 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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newPlanMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); } - init { this._rawData.Set("default_unit_rate", value); } } - /// - /// An optional key in the event data to group by (e.g., event ID). All events - /// will also be grouped by their unit rate. - /// - public string? GroupingKey + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + 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, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); } - init { this._rawData.Set("grouping_key", value); } - } - - /// - public override void Validate() - { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; - } - - public EventOutputConfig() { } - - public EventOutputConfig(global::Orb.Models.Beta.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } - - public EventOutputConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) - { - this._rawData = new(rawData); } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public double? ConversionRate { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + 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, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newPlanMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() + public string? Currency { - this.UnitRatingKey = unitRatingKey; - } -} - -class EventOutputConfigFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter(typeof(global::Orb.Models.Beta.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; + 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, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newPlanMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } + } - public JsonElement Json + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions + 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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration ); } } - public EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } - - public EventOutputConversionRateConfig(JsonElement element) + public string? ExternalPriceID { - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.ExternalPriceID, + newPlanTiered: (x) => x.ExternalPriceID, + newPlanBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newPlanPackage: (x) => x.ExternalPriceID, + newPlanMatrix: (x) => x.ExternalPriceID, + newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, + newPlanTieredPackage: (x) => x.ExternalPriceID, + newPlanTieredWithMinimum: (x) => x.ExternalPriceID, + newPlanGroupedTiered: (x) => x.ExternalPriceID, + newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newPlanPackageWithAllocation: (x) => x.ExternalPriceID, + newPlanUnitWithPercent: (x) => x.ExternalPriceID, + newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newPlanUnitWithProration: (x) => x.ExternalPriceID, + newPlanGroupedAllocation: (x) => x.ExternalPriceID, + newPlanBulkWithProration: (x) => x.ExternalPriceID, + newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, + newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, + newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + 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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public double? FixedPriceQuantity { - value = this.Value as SharedUnitConversionRateConfig; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.FixedPriceQuantity, + newPlanTiered: (x) => x.FixedPriceQuantity, + newPlanBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newPlanPackage: (x) => x.FixedPriceQuantity, + newPlanMatrix: (x) => x.FixedPriceQuantity, + newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newPlanTieredPackage: (x) => x.FixedPriceQuantity, + newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedTiered: (x) => x.FixedPriceQuantity, + newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, + newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, + newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newPlanUnitWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, + newPlanBulkWithProration: (x) => x.FixedPriceQuantity, + newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + 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.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public string? InvoiceGroupingKey { - value = this.Value as SharedTieredConversionRateConfig; - return value != null; + get + { + return Match( + newPlanUnit: (x) => x.InvoiceGroupingKey, + newPlanTiered: (x) => x.InvoiceGroupingKey, + newPlanBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newPlanPackage: (x) => x.InvoiceGroupingKey, + newPlanMatrix: (x) => x.InvoiceGroupingKey, + newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newPlanTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, + newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, + newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - 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 EventOutputConversionRateConfig" - ); + 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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) + public string? LicenseTypeID { - return this.Value switch + get { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" - ), - }; + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } } - public static implicit operator global::Orb.Models.Beta.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.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() + public string? ReferenceID { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + 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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.EventOutputConversionRateConfig? other) + public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this.Value = value; + this._element = element; } - public override int GetHashCode() + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) { - return 0; + this.Value = value; + this._element = element; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class EventOutputConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.EventOutputConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch - { - conversionRateType = null; - } + this.Value = value; + this._element = element; + } - switch (conversionRateType) - { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - return new(element); - } - default: - { - return new global::Orb.Models.Beta.EventOutputConversionRateConfig(element); - } - } + public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.EventOutputConversionRateConfig value, - JsonSerializerOptions options - ) + public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel -{ - /// - /// The id of the adjustment to remove from on the plan. - /// - public required string AdjustmentID + public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); - } - init { this._rawData.Set("adjustment_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to remove this adjustment from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public RemoveAdjustment() { } + public ReplacePricePrice( + NewPlanTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } + public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public RemoveAdjustment(IReadOnlyDictionary rawData) + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) { - this.AdjustmentID = adjustmentID; + this.Value = value; + this._element = element; } -} - -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 + public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); - } - init { this._rawData.Set("price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to remove this price from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - _ = this.PriceID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) + public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) { - this.PriceID = priceID; + this.Value = value; + this._element = element; } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - RemovePrice.FromRawUnchecked(rawData); -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplaceAdjustment : JsonModel -{ - /// - /// The definition of a new adjustment to create and add to the plan. - /// - public required ReplaceAdjustmentAdjustment Adjustment + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); - } - init { this._rawData.Set("adjustment", value); } + this.Value = value; + this._element = element; } - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); - } - init { this._rawData.Set("replaces_adjustment_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + public ReplacePricePrice( + ReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplacePricePrice(ReplacePricePriceMeteredAllowance value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } -} -class ReplaceAdjustmentFromRaw : IFromRawJson -{ - /// - public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplaceAdjustment.FromRawUnchecked(rawData); -} + public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } -/// -/// 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; + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - JsonElement? _element = null; + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice(JsonElement element) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this._element = element; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - get - { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency - ); - } + value = this.Value as NewPlanUnitPrice; + return value != null; } - public bool? IsInvoiceLevel + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - get - { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel - ); - } + value = this.Value as NewPlanTieredPrice; + return value != null; } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount 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.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanBulkPrice; + return value != null; } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - this.Value = value; - this._element = element; + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != null; } - public ReplaceAdjustmentAdjustment(NewAmountDiscount 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.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanPackagePrice; + return value != null; } - public ReplaceAdjustmentAdjustment(NewMinimum 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.TryPickNewPlanMatrix(out var value)) { + /// // `value` is of type `NewPlanMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanMatrixPrice; + return value != null; } - public ReplaceAdjustmentAdjustment(NewMaximum 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.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value + ) { - this.Value = value; - this._element = element; + value = this.Value as NewPlanThresholdTotalAmountPrice; + return value != null; } - public ReplaceAdjustmentAdjustment(JsonElement element) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanTieredPackage(out var value)) { + /// // `value` is of type `NewPlanTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanTieredPackage( + [NotNullWhen(true)] out NewPlanTieredPackagePrice? value + ) { - this._element = element; + 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 . + /// 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.TryPickNewPlanTieredWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredWithMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public bool TryPickNewPlanTieredWithMinimum( + [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value + ) { - value = this.Value as NewPercentageDiscount; + 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 . + /// 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.TryPickNewPlanGroupedTiered(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public bool TryPickNewPlanGroupedTiered( + [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value + ) { - value = this.Value as NewUsageDiscount; + 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 . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` + /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { + /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public bool TryPickNewPlanTieredPackageWithMinimum( + [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value + ) { - value = this.Value as NewAmountDiscount; + 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 . + /// 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.TryPickNewPlanPackageWithAllocation(out var value)) { + /// // `value` is of type `NewPlanPackageWithAllocationPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public bool TryPickNewPlanPackageWithAllocation( + [NotNullWhen(true)] out NewPlanPackageWithAllocationPrice? value + ) { - value = this.Value as NewMinimum; + 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 . + /// 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.TryPickNewPlanUnitWithPercent(out var value)) { + /// // `value` is of type `NewPlanUnitWithPercentPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public bool TryPickNewPlanUnitWithPercent( + [NotNullWhen(true)] out NewPlanUnitWithPercentPrice? value + ) { - value = this.Value as NewMaximum; + value = this.Value as NewPlanUnitWithPercentPrice; 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.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. /// /// /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); + /// if (instance.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } /// /// /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value ) { - 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" - ); - } + value = this.Value as ReplacePricePriceTieredWithProration; + return value != 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. + /// 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. /// /// /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); + /// if (instance.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } /// /// /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value ) { - 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" - ), - }; + value = this.Value as NewPlanUnitWithProrationPrice; + return value != null; } - 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). + /// 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.TryPickNewPlanGroupedAllocation(out var value)) { + /// // `value` is of type `NewPlanGroupedAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - 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) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } - - public override int GetHashCode() - { - return 0; - } - - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter -{ - public override ReplaceAdjustmentAdjustment? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } - - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } - } - - public override void Write( - Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, - JsonSerializerOptions options + public bool TryPickNewPlanGroupedAllocation( + [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value ) { - JsonSerializer.Serialize(writer, value.Json, options); + value = this.Value as NewPlanGroupedAllocationPrice; + return value != null; } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel -{ /// - /// The id of the price on the plan to replace in the plan. + /// Returns true and sets the 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 required string ReplacesPriceID + public bool TryPickNewPlanBulkWithProration( + [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + value = this.Value as NewPlanBulkWithProrationPrice; + return value != null; } /// - /// The allocation price to add to the plan. + /// Returns true and sets the 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 NewAllocationPrice? AllocationPrice + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + value = this.Value as NewPlanGroupedWithProratedMinimumPrice; + return value != null; } /// - /// The phase to replace this price from. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedWithMeteredMinimum(out var value)) { + /// // `value` is of type `NewPlanGroupedWithMeteredMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public long? PlanPhaseOrder + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; + return value != null; } /// - /// New plan price request body params. + /// Returns true and sets the 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 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 - ); - } - } - - public string Name + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (x) => x.Name, - newPlanMinimumComposite: (x) => x.Name, - percent: (x) => x.Name, - eventOutput: (x) => x.Name - ); - } + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; + return value != null; } - public string? BillableMetricID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { + /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMatrixWithDisplayName( + [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + value = this.Value as NewPlanMatrixWithDisplayNamePrice; + return value != null; } - public bool? BilledInAdvance + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTieredPackage( + [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + value = this.Value as NewPlanGroupedTieredPackagePrice; + return value != null; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMaxGroupTieredPackage( + [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newPlanPackage: (x) => x.BillingCycleConfiguration, - newPlanMatrix: (x) => x.BillingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newPlanTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewPlanMaxGroupTieredPackagePrice; + return value != null; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newPlanPackage: (x) => x.ConversionRate, - newPlanMatrix: (x) => x.ConversionRate, - newPlanThresholdTotalAmount: (x) => x.ConversionRate, - newPlanTieredPackage: (x) => x.ConversionRate, - newPlanTieredWithMinimum: (x) => x.ConversionRate, - newPlanGroupedTiered: (x) => x.ConversionRate, - newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, - newPlanPackageWithAllocation: (x) => x.ConversionRate, - newPlanUnitWithPercent: (x) => x.ConversionRate, - newPlanMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newPlanUnitWithProration: (x) => x.ConversionRate, - newPlanGroupedAllocation: (x) => x.ConversionRate, - newPlanBulkWithProration: (x) => x.ConversionRate, - newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, - newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newPlanMatrixWithDisplayName: (x) => x.ConversionRate, - newPlanGroupedTieredPackage: (x) => x.ConversionRate, - newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, - newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; + return value != null; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.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 + ) { - get - { - return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newPlanPackage: (x) => x.Currency, - newPlanMatrix: (x) => x.Currency, - newPlanThresholdTotalAmount: (x) => x.Currency, - newPlanTieredPackage: (x) => x.Currency, - newPlanTieredWithMinimum: (x) => x.Currency, - newPlanGroupedTiered: (x) => x.Currency, - newPlanTieredPackageWithMinimum: (x) => x.Currency, - newPlanPackageWithAllocation: (x) => x.Currency, - newPlanUnitWithPercent: (x) => x.Currency, - newPlanMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newPlanUnitWithProration: (x) => x.Currency, - newPlanGroupedAllocation: (x) => x.Currency, - newPlanBulkWithProration: (x) => x.Currency, - newPlanGroupedWithProratedMinimum: (x) => x.Currency, - newPlanGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newPlanMatrixWithDisplayName: (x) => x.Currency, - newPlanGroupedTieredPackage: (x) => x.Currency, - newPlanMaxGroupTieredPackage: (x) => x.Currency, - newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, - newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, - newPlanCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as NewPlanCumulativeGroupedBulkPrice; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { + /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickCumulativeGroupedAllocation( + [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newPlanPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMatrix: (x) => x.DimensionalPriceConfiguration, - newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickDailyCreditAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceDailyCreditAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickDailyCreditAllowance( + [NotNullWhen(true)] out ReplacePricePriceDailyCreditAllowance? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newPlanPackage: (x) => x.ExternalPriceID, - newPlanMatrix: (x) => x.ExternalPriceID, - newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, - newPlanTieredPackage: (x) => x.ExternalPriceID, - newPlanTieredWithMinimum: (x) => x.ExternalPriceID, - newPlanGroupedTiered: (x) => x.ExternalPriceID, - newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newPlanPackageWithAllocation: (x) => x.ExternalPriceID, - newPlanUnitWithPercent: (x) => x.ExternalPriceID, - newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newPlanUnitWithProration: (x) => x.ExternalPriceID, - newPlanGroupedAllocation: (x) => x.ExternalPriceID, - newPlanBulkWithProration: (x) => x.ExternalPriceID, - newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, - newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, - newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as ReplacePricePriceDailyCreditAllowance; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] out ReplacePricePriceMeteredAllowance? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as ReplacePricePriceMeteredAllowance; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { + /// // `value` is of type `NewPlanMinimumCompositePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMinimumComposite( + [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.InvoiceGroupingKey, - newPlanTiered: (x) => x.InvoiceGroupingKey, - newPlanBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newPlanPackage: (x) => x.InvoiceGroupingKey, - newPlanMatrix: (x) => x.InvoiceGroupingKey, - newPlanThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newPlanTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedTiered: (x) => x.InvoiceGroupingKey, - newPlanTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newPlanPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newPlanUnitWithPercent: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newPlanUnitWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedAllocation: (x) => x.InvoiceGroupingKey, - newPlanBulkWithProration: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newPlanMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newPlanGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newPlanCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewPlanMinimumCompositePrice; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - get - { - return Match( - newPlanUnit: (x) => x.InvoicingCycleConfiguration, - newPlanTiered: (x) => x.InvoicingCycleConfiguration, - newPlanBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newPlanPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMatrix: (x) => x.InvoicingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newPlanBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.InvoicingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } + value = this.Value as ReplacePricePricePercent; + return value != null; } - public string? ReferenceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - get + value = this.Value as ReplacePricePriceEventOutput; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (NewPlanUnitPrice value) => {...}, + /// (NewPlanTieredPrice value) => {...}, + /// (NewPlanBulkPrice value) => {...}, + /// (ReplacePricePriceBulkWithFilters value) => {...}, + /// (NewPlanPackagePrice value) => {...}, + /// (NewPlanMatrixPrice value) => {...}, + /// (NewPlanThresholdTotalAmountPrice value) => {...}, + /// (NewPlanTieredPackagePrice value) => {...}, + /// (NewPlanTieredWithMinimumPrice value) => {...}, + /// (NewPlanGroupedTieredPrice value) => {...}, + /// (NewPlanTieredPackageWithMinimumPrice value) => {...}, + /// (NewPlanPackageWithAllocationPrice value) => {...}, + /// (NewPlanUnitWithPercentPrice value) => {...}, + /// (NewPlanMatrixWithAllocationPrice value) => {...}, + /// (ReplacePricePriceTieredWithProration value) => {...}, + /// (NewPlanUnitWithProrationPrice value) => {...}, + /// (NewPlanGroupedAllocationPrice value) => {...}, + /// (NewPlanBulkWithProrationPrice value) => {...}, + /// (NewPlanGroupedWithProratedMinimumPrice value) => {...}, + /// (NewPlanGroupedWithMeteredMinimumPrice value) => {...}, + /// (ReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewPlanMatrixWithDisplayNamePrice value) => {...}, + /// (NewPlanGroupedTieredPackagePrice value) => {...}, + /// (NewPlanMaxGroupTieredPackagePrice value) => {...}, + /// (NewPlanScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewPlanScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewPlanCumulativeGroupedBulkPrice value) => {...}, + /// (ReplacePricePriceCumulativeGroupedAllocation value) => {...}, + /// (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 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) { - 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 - ); + 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 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" + ); } } - public ReplacePricePrice(NewPlanUnitPrice 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( + /// (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) => {...}, + /// (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 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 + ) { - this.Value = value; - this._element = element; + return this.Value switch + { + NewPlanUnitPrice value => newPlanUnit(value), + NewPlanTieredPrice value => newPlanTiered(value), + NewPlanBulkPrice value => newPlanBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewPlanPackagePrice value => newPlanPackage(value), + NewPlanMatrixPrice value => newPlanMatrix(value), + NewPlanThresholdTotalAmountPrice value => newPlanThresholdTotalAmount(value), + NewPlanTieredPackagePrice value => newPlanTieredPackage(value), + NewPlanTieredWithMinimumPrice value => newPlanTieredWithMinimum(value), + NewPlanGroupedTieredPrice value => newPlanGroupedTiered(value), + NewPlanTieredPackageWithMinimumPrice value => newPlanTieredPackageWithMinimum(value), + NewPlanPackageWithAllocationPrice value => newPlanPackageWithAllocation(value), + NewPlanUnitWithPercentPrice value => newPlanUnitWithPercent(value), + NewPlanMatrixWithAllocationPrice value => newPlanMatrixWithAllocation(value), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewPlanUnitWithProrationPrice value => newPlanUnitWithProration(value), + NewPlanGroupedAllocationPrice value => newPlanGroupedAllocation(value), + NewPlanBulkWithProrationPrice value => newPlanBulkWithProration(value), + NewPlanGroupedWithProratedMinimumPrice value => newPlanGroupedWithProratedMinimum( + value + ), + NewPlanGroupedWithMeteredMinimumPrice value => newPlanGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewPlanMatrixWithDisplayNamePrice value => newPlanMatrixWithDisplayName(value), + NewPlanGroupedTieredPackagePrice value => newPlanGroupedTieredPackage(value), + NewPlanMaxGroupTieredPackagePrice value => newPlanMaxGroupTieredPackage(value), + NewPlanScalableMatrixWithUnitPricingPrice value => newPlanScalableMatrixWithUnitPricing( + value + ), + NewPlanScalableMatrixWithTieredPricingPrice value => + newPlanScalableMatrixWithTieredPricing(value), + NewPlanCumulativeGroupedBulkPrice value => newPlanCumulativeGroupedBulk(value), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + 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 ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); - public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); + + public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => + new(value); + + public static implicit operator ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value + ) => new(value); - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + ReplacePricePriceDailyCreditAllowance value + ) => new(value); - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceMeteredAllowance value) => + new(value); - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => + new(value); - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => + new(value); - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds 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 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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) + public override int GetHashCode() { - this.Value = value; - this._element = element; + return 0; } - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + int VariantIndex() { - this.Value = value; - this._element = element; + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + ReplacePricePriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + ReplacePricePriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + ReplacePricePriceDailyCreditAllowance _ => 28, + ReplacePricePriceMeteredAllowance _ => 29, + NewPlanMinimumCompositePrice _ => 30, + ReplacePricePricePercent _ => 31, + ReplacePricePriceEventOutput _ => 32, + _ => -1, + }; } +} - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null +sealed class ReplacePricePriceConverter : JsonConverter +{ + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; - } + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + 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 + } - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + 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 + } - /// - /// Returns true and sets the 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; - } + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `ReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value - ) - { - value = this.Value as ReplacePricePriceBulkWithFilters; - return value != null; - } + return new(element); + } + case "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 + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) - { - value = this.Value as NewPlanPackagePrice; - return value != null; - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) - { - value = this.Value as NewPlanMatrixPrice; - return value != null; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) - { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; - } + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) - { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; - } + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) - { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) - { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; - } + return new(element); + } + case "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 + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value - ) - { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; - } + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + 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 + } - /// - /// Returns true and sets the 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 "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 + } - /// - /// Returns true and sets the 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "metered_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) - { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + return 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); + } + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewPlanMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrixWithDisplayName( - [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value + public override void Write( + Utf8JsonWriter writer, + ReplacePricePrice? value, + JsonSerializerOptions options ) { - value = this.Value as NewPlanMatrixWithDisplayNamePrice; - return value != null; + JsonSerializer.Serialize(writer, value?.Json, options); } +} +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFilters : 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.TryPickNewPlanGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTieredPackage( - [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value - ) + /// Configuration for bulk_with_filters pricing + /// + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig { - value = this.Value as NewPlanGroupedTieredPackagePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_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.TryPickNewPlanMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The cadence to bill for this price on. /// - public bool TryPickNewPlanMaxGroupTieredPackage( - [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value - ) + public required ApiEnum Cadence { - value = this.Value as NewPlanMaxGroupTieredPackagePrice; - 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.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickNewPlanScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value - ) + public required string ItemID { - value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; - 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.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The pricing model type /// - public bool TryPickNewPlanScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value - ) + public JsonElement ModelType { - value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; - 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.TryPickNewPlanCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The name of the price. /// - public bool TryPickNewPlanCumulativeGroupedBulk( - [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value - ) + public required string Name { - value = this.Value as NewPlanCumulativeGroupedBulkPrice; - 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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) + public string? BillableMetricID { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// 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 TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) + public bool? BilledInAdvance { - value = this.Value as ReplacePricePriceMinimum; - 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewPlanMinimumCompositePrice; - 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.TryPickPercent(out var value)) { - /// // `value` is of type `ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) + public double? ConversionRate { - value = this.Value as ReplacePricePricePercent; - 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// + /// The configuration for the rate of the price currency to the invoicing currency. /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) + public ReplacePricePriceBulkWithFiltersConversionRateConfig? ConversionRateConfig { - value = this.Value as ReplacePricePriceEventOutput; - return value != null; + 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. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the 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) => {...} - /// ); - /// - /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values /// - 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 NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - 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( + "dimensional_price_configuration" + ); } + init { this._rawData.Set("dimensional_price_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) => {...} - /// ); - /// - /// + /// An alias for the 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? ExternalPriceID { - 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("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } } - public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } - public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } - public static implicit operator ReplacePricePrice(NewPlanBulkPrice 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(ReplacePricePriceBulkWithFilters 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(NewPlanPackagePrice 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(NewPlanMatrixPrice value) => new(value); + /// + public override void Validate() + { + this.BulkWithFiltersConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_filters") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => - new(value); + public ReplacePricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters + ) + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => - new(value); + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => - new(value); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => - new(value); + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => - new(value); +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => - new(value); +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => - new(value); + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } - public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => - new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => - new(value); +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => - new(value); +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } - public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => - new(value); + /// + /// Event property value to match + /// + public required string PropertyValue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } + } - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + /// + public override void Validate() + { + _ = this.PropertyKey; + _ = this.PropertyValue; + } - public static implicit operator ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter() { } - public static implicit operator ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value) => - new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter) { } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator ReplacePricePrice(NewPlanMinimumCompositePrice value) => - new(value); + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel +{ + /// + /// Amount per unit + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This 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 lower bound for this tier /// - public override void Validate() + public string? TierLowerBound { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("tier_lower_bound"); } - 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("tier_lower_bound", value); } } - public virtual bool Equals(ReplacePricePrice? other) + /// + public override void Validate() { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + _ = this.UnitAmount; + _ = this.TierLowerBound; } - public override int GetHashCode() + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 + + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) { - return 0; + 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; } +} - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(rawData); } -sealed class ReplacePricePriceConverter : JsonConverter +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence { - public override ReplacePricePrice? Read( + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence 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) + return JsonSerializer.Deserialize(ref reader, options) switch { - case "unit": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "grouped_tiered": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "tiered_package_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } - return new(element); - } - case "package_with_allocation": + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence 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 - } + 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 + ); + } +} - 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 - } +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = 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 - } + JsonElement? _element = 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 - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "unit_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + { + 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 - } + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `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_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.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } - return new(element); - } - case "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 and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + 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(ReplacePricePriceBulkWithFiltersConversionRateConfig? 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": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } - return new(element); - } - case "percent": + switch (conversionRateType) + { + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "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 +16906,39 @@ JsonSerializerOptions options } default: { - return new ReplacePricePrice(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePrice? value, + ReplacePricePriceBulkWithFiltersConversionRateConfig 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 +16983,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 +17057,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 +17153,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17204,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 +17228,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 +17270,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 +17399,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -13443,76 +17407,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 +17498,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -13529,93 +17506,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 +17543,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -13641,7 +17552,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -13650,7 +17561,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -13659,7 +17570,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 +17591,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +17611,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +17622,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -13732,7 +17643,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 +17652,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +17663,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -13768,16 +17679,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 +17707,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 +17724,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 +17772,10 @@ JsonSerializerOptions 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 +17792,10 @@ JsonSerializerOptions 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 +17804,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 +17821,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 +17896,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 +17955,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 +18051,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18103,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 +18126,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 +18170,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 +18193,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 +18204,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 +18224,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 +18240,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 +18331,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -14461,8 +18339,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14470,18 +18348,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 +18378,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14507,7 +18387,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14516,7 +18396,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -14525,7 +18405,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 +18426,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18446,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18457,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14598,7 +18478,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 +18487,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18498,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14634,16 +18514,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 +18542,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 +18561,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 +18609,10 @@ JsonSerializerOptions 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 +18629,10 @@ JsonSerializerOptions 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 +18641,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 +18660,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 +18794,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 +18890,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18942,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 +18965,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 +19009,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 +19032,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 +19043,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 +19063,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 +19079,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 +19170,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -15265,8 +19178,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15274,20 +19187,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 +19217,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15313,7 +19226,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15322,7 +19235,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15331,7 +19244,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 +19265,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +19285,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +19296,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15404,7 +19317,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 +19326,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +19337,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15440,16 +19353,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 +19381,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 +19400,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 +19448,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15544,12 +19468,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -15558,7 +19480,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -15567,7 +19489,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15577,40 +19499,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 +19633,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 +19729,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19781,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 +19804,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 +19846,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 +19869,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 +19880,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 +20113,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 +20136,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -16075,8 +20144,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16084,20 +20153,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 +20183,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16123,7 +20192,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16132,7 +20201,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16141,7 +20210,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 +20231,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +20251,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +20262,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16214,7 +20283,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 +20292,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +20303,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16250,16 +20319,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 +20347,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 +20364,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 +20412,10 @@ JsonSerializerOptions 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 +20432,10 @@ JsonSerializerOptions 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 +20444,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 +20460,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 +20496,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 +20595,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 +20691,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +20744,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 +20766,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 +20808,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 +20830,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 +20841,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 +20861,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 +20877,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 +20982,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 +21060,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16899,7 +21069,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16908,7 +21078,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16917,7 +21087,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 +21108,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21128,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21139,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16990,7 +21160,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 +21169,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21180,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17026,16 +21196,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 +21224,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 +21241,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 +21289,10 @@ JsonSerializerOptions 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 +21309,10 @@ JsonSerializerOptions 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 +21321,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 +21565,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +21635,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -17452,8 +21645,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 +21775,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 +21866,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 +21887,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21907,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21918,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17749,7 +21948,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21959,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17810,10 +22009,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 +22020,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +22068,10 @@ JsonSerializerOptions 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 +22088,10 @@ JsonSerializerOptions 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 +22344,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22419,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18207,8 +22429,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 +22590,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 +22683,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 +22704,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +22724,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +22735,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18537,7 +22765,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +22776,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18598,10 +22826,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 +22837,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +22885,10 @@ JsonSerializerOptions 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 +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 } 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..e6a82b88c 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,2784 +949,6222 @@ 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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(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` - /// Console.WriteLine(value); + /// 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. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// 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. /// /// /// - /// 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.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< - 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 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.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 NewPlanPackagePrice; + 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); + /// + /// Returns true and sets the 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.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.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 "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.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 "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.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 "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.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 "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.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 "tiered_package": - { + /// + /// Returns true and sets the 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) => {...}, + /// (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 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 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"); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was 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) => {...}, + /// (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 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), + 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"), + }; + } + + public static implicit operator Price(NewPlanUnitPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanBulkPrice value) => new(value); + + public static implicit operator Price(BulkWithFilters value) => new(value); + + public static implicit operator Price(NewPlanPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixPrice value) => new(value); + + public static implicit operator Price(NewPlanThresholdTotalAmountPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackagePrice value) => new(value); + + public static implicit operator Price(NewPlanTieredWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanGroupedTieredPrice value) => new(value); + + public static implicit operator Price(NewPlanTieredPackageWithMinimumPrice value) => new(value); + + public static implicit operator Price(NewPlanPackageWithAllocationPrice value) => new(value); + + public static implicit operator Price(NewPlanUnitWithPercentPrice value) => new(value); + + public static implicit operator Price(NewPlanMatrixWithAllocationPrice value) => new(value); + + public static implicit operator Price(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); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException("Data did not match any variant of Price"); + } + this.Switch( + (newPlanUnit) => newPlanUnit.Validate(), + (newPlanTiered) => newPlanTiered.Validate(), + (newPlanBulk) => newPlanBulk.Validate(), + (bulkWithFilters) => bulkWithFilters.Validate(), + (newPlanPackage) => newPlanPackage.Validate(), + (newPlanMatrix) => newPlanMatrix.Validate(), + (newPlanThresholdTotalAmount) => newPlanThresholdTotalAmount.Validate(), + (newPlanTieredPackage) => newPlanTieredPackage.Validate(), + (newPlanTieredWithMinimum) => newPlanTieredWithMinimum.Validate(), + (newPlanGroupedTiered) => newPlanGroupedTiered.Validate(), + (newPlanTieredPackageWithMinimum) => newPlanTieredPackageWithMinimum.Validate(), + (newPlanPackageWithAllocation) => newPlanPackageWithAllocation.Validate(), + (newPlanUnitWithPercent) => newPlanUnitWithPercent.Validate(), + (newPlanMatrixWithAllocation) => newPlanMatrixWithAllocation.Validate(), + (tieredWithProration) => tieredWithProration.Validate(), + (newPlanUnitWithProration) => newPlanUnitWithProration.Validate(), + (newPlanGroupedAllocation) => newPlanGroupedAllocation.Validate(), + (newPlanBulkWithProration) => newPlanBulkWithProration.Validate(), + (newPlanGroupedWithProratedMinimum) => newPlanGroupedWithProratedMinimum.Validate(), + (newPlanGroupedWithMeteredMinimum) => newPlanGroupedWithMeteredMinimum.Validate(), + (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), + (newPlanMatrixWithDisplayName) => newPlanMatrixWithDisplayName.Validate(), + (newPlanGroupedTieredPackage) => newPlanGroupedTieredPackage.Validate(), + (newPlanMaxGroupTieredPackage) => newPlanMaxGroupTieredPackage.Validate(), + (newPlanScalableMatrixWithUnitPricing) => + newPlanScalableMatrixWithUnitPricing.Validate(), + (newPlanScalableMatrixWithTieredPricing) => + newPlanScalableMatrixWithTieredPricing.Validate(), + (newPlanCumulativeGroupedBulk) => newPlanCumulativeGroupedBulk.Validate(), + (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); + } + + public virtual bool Equals(Price? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + NewPlanMinimumCompositePrice _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -1, + }; + } +} + +sealed class PriceConverter : JsonConverter +{ + public override Price? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } + + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_tiered_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_bulk": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "cumulative_grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "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 Price(element); + } + } + } + + public override void Write(Utf8JsonWriter writer, Price? value, JsonSerializerOptions options) + { + JsonSerializer.Serialize(writer, value?.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new BulkWithFiltersConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class TieredWithProration : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" + ); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// Configuration for tiered_with_proration pricing + /// + public required TieredWithProrationConfig TieredWithProrationConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "tiered_with_proration_config" + ); + } + init { this._rawData.Set("tiered_with_proration_config", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public TieredWithProrationConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("tiered_with_proration") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + this.TieredWithProrationConfig.Validate(); + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public TieredWithProration() + { + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) + : base(tieredWithProration) { } +#pragma warning restore CS8618 + + public TieredWithProration(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProration(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProration FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationFromRaw : IFromRawJson +{ + /// + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] +public enum TieredWithProrationCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class TieredWithProrationCadenceConverter : JsonConverter +{ + public override TieredWithProrationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for tiered_with_proration pricing +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfig : JsonModel +{ + /// + /// Tiers for rating based on total usage quantities into the specified tier + /// with proration + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "tiers" + ); + } + init + { + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + public override void Validate() + { + foreach (var item in this.Tiers) + { + item.Validate(); + } + } + + public TieredWithProrationConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) + : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfig(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfig(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public TieredWithProrationConfig(IReadOnlyList tiers) + : this() + { + this.Tiers = tiers; + } +} + +class TieredWithProrationConfigFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); +} + +/// +/// Configuration for a single tiered with proration tier +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class TieredWithProrationConfigTier : JsonModel +{ + /// + /// Inclusive tier starting value + /// + public required string TierLowerBound + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } + + /// + /// Amount per unit + /// + public required string UnitAmount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); + } + init { this._rawData.Set("unit_amount", value); } + } + + /// + public override void Validate() + { + _ = this.TierLowerBound; + _ = this.UnitAmount; + } + + public TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier + ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationConfigTierFromRaw : IFromRawJson +{ + /// + public TieredWithProrationConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] +public record class TieredWithProrationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public TieredWithProrationConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ), + }; + } + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator TieredWithProrationConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of TieredWithProrationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class TieredWithProrationConversionRateConfigConverter + : JsonConverter +{ + public override TieredWithProrationConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { try { - var deserialized = JsonSerializer.Deserialize( + 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_with_minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + return new(element); + } + default: + { + return new TieredWithProrationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + TieredWithProrationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedWithMinMaxThresholds : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// Configuration for grouped_with_min_max_thresholds pricing + /// + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "grouped_with_min_max_thresholds_config" + ); + } + init { this._rawData.Set("grouped_with_min_max_thresholds_config", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// The pricing model type + /// + public JsonElement ModelType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", value); } + } + + /// + /// The name of the price. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } + } + + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this is false. + /// + public bool? BilledInAdvance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("billed_in_advance"); + } + init { this._rawData.Set("billed_in_advance", value); } + } + + /// + /// For custom cadence: specifies the duration of the billing period in days + /// or months. + /// + public NewBillingCycleConfiguration? BillingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); + } + init { this._rawData.Set("billing_cycle_configuration", value); } + } + + /// + /// The per unit conversion rate of the price currency to the invoicing currency. + /// + public double? ConversionRate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("conversion_rate"); + } + init { this._rawData.Set("conversion_rate", value); } + } + + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } + } + + /// + /// An ISO 4217 currency string, or custom pricing unit identifier, in which + /// this price is billed. + /// + public string? Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// For dimensional price: specifies a price group and dimension values + /// + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "dimensional_price_configuration" + ); + } + init { this._rawData.Set("dimensional_price_configuration", value); } + } + + /// + /// An alias for the price. + /// + public string? ExternalPriceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_price_id"); + } + init { this._rawData.Set("external_price_id", value); } + } + + /// + /// If the Price represents a fixed cost, this represents the quantity of units applied. + /// + public double? FixedPriceQuantity + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("fixed_price_quantity"); + } + init { this._rawData.Set("fixed_price_quantity", value); } + } + + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } + } + + /// + /// Within each billing cycle, specifies the cadence at which invoices are produced. + /// If unspecified, a single invoice is produced per billing cycle. + /// + public NewBillingCycleConfiguration? InvoicingCycleConfiguration + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } + } + + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); + } + init { this._rawData.Set("reference_id", value); } + } + + /// + public override void Validate() + { + this.Cadence.Validate(); + this.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } + + public GroupedWithMinMaxThresholds() + { + this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + } - 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 GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) + : base(groupedWithMinMaxThresholds) { } +#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 GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); - return new(element); - } - case "package_with_allocation": + 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 { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + 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 - 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 GroupedWithMinMaxThresholdsConfig 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 GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsConfig.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(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] +public record class GroupedWithMinMaxThresholdsConversionRateConfig : 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 GroupedWithMinMaxThresholdsConversionRateConfig( + 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 GroupedWithMinMaxThresholdsConversionRateConfig( + 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 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" + ); + } + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + ), + }; + } - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); - return new(element); - } - case "max_group_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } - return new(element); - } - case "scalable_matrix_with_unit_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - return new(element); - } - case "scalable_matrix_with_tiered_pricing": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override int GetHashCode() + { + return 0; + } - return new(element); - } - case "cumulative_grouped_bulk": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - return new(element); - } - case "cumulative_grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} - 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 - } +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; + } - return new(element); - } - case "minimum_composite": + 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 } @@ -3690,57 +7173,54 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.Price(element); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Price? value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { - JsonSerializer.Serialize(writer, value?.Json, options); + JsonSerializer.Serialize(writer, value.Json, options); } } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class BulkWithFilters : JsonModel +public sealed record class CumulativeGroupedAllocation : JsonModel { /// - /// Configuration for bulk_with_filters pricing + /// The cadence to bill for this price on. /// - public required global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig BulkWithFiltersConfig + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "bulk_with_filters_config" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } - init { this._rawData.Set("bulk_with_filters_config", value); } + init { this._rawData.Set("cadence", value); } } /// - /// The cadence to bill for this price on. + /// Configuration for cumulative_grouped_allocation pricing /// - public required ApiEnum Cadence + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass( + "cumulative_grouped_allocation_config" + ); } - init { this._rawData.Set("cadence", value); } + init { this._rawData.Set("cumulative_grouped_allocation_config", value); } } /// @@ -3841,12 +7321,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -3937,6 +7417,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -3975,13 +7468,13 @@ public string? ReferenceID /// public override void Validate() { - this.BulkWithFiltersConfig.Validate(); this.Cadence.Validate(); + this.CumulativeGroupedAllocationConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("bulk_with_filters") + JsonSerializer.SerializeToElement("cumulative_grouped_allocation") ) ) { @@ -3999,35 +7492,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public BulkWithFilters() + public CumulativeGroupedAllocation() { - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public BulkWithFilters(global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters bulkWithFilters) - : base(bulkWithFilters) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) + : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 - public BulkWithFilters(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } #pragma warning disable CS8618 [SetsRequiredMembers] - BulkWithFilters(FrozenDictionary rawData) + CumulativeGroupedAllocation(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4035,344 +7532,188 @@ IReadOnlyDictionary rawData } } -class BulkWithFiltersFromRaw : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFilters.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// -/// Configuration for bulk_with_filters pricing +/// The cadence to bill for this price on. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig, - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfigFromRaw - >) -)] -public sealed record class BulkWithFiltersConfig : JsonModel +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] +public enum CumulativeGroupedAllocationCadence { - /// - /// Property filters to apply (all must match) - /// - public required IReadOnlyList Filters - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); - } - init - { - this._rawData.Set>( - "filters", - ImmutableArray.ToImmutableArray(value) - ); - } - } - - /// - /// Bulk tiers for rating based on total usage volume - /// - public required IReadOnlyList Tiers - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); - } - init - { - this._rawData.Set>( - "tiers", - ImmutableArray.ToImmutableArray(value) - ); - } - } - - /// - public override void Validate() - { - foreach (var item in this.Filters) - { - item.Validate(); - } - foreach (var item in this.Tiers) - { - item.Validate(); - } - } - - public BulkWithFiltersConfig() { } + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - public BulkWithFiltersConfig( - global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig bulkWithFiltersConfig +sealed class CumulativeGroupedAllocationCadenceConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) - : base(bulkWithFiltersConfig) { } - - public BulkWithFiltersConfig(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - BulkWithFiltersConfig(FrozenDictionary rawData) { - this._rawData = new(rawData); + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), + }; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationCadence value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + JsonSerializer.Serialize( + writer, + value switch + { + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } } -class BulkWithFiltersConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.BulkWithFiltersConfig.FromRawUnchecked(rawData); -} - /// -/// Configuration for a single property filter +/// Configuration for cumulative_grouped_allocation pricing /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Filter, - global::Orb.Models.Beta.ExternalPlanID.FilterFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] -public sealed record class Filter : JsonModel +public sealed record class CumulativeGroupedAllocationConfig : JsonModel { /// - /// Event property key to filter on + /// The overall allocation across all groups /// - public required string PropertyKey + public required string CumulativeAllocation { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_key"); + return this._rawData.GetNotNullClass("cumulative_allocation"); } - init { this._rawData.Set("property_key", value); } + init { this._rawData.Set("cumulative_allocation", value); } } /// - /// Event property value to match + /// The allocation per individual group /// - public required string PropertyValue - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("property_value"); - } - init { this._rawData.Set("property_value", value); } - } - - /// - public override void Validate() - { - _ = this.PropertyKey; - _ = this.PropertyValue; - } - - public Filter() { } - - public Filter(global::Orb.Models.Beta.ExternalPlanID.Filter filter) - : base(filter) { } - - public Filter(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Filter(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public required string GroupAllocation { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("group_allocation"); + } + init { this._rawData.Set("group_allocation", value); } } -} - -class FilterFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Filter.FromRawUnchecked(rawData); -} -/// -/// Configuration for a single bulk pricing tier -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Tier, - global::Orb.Models.Beta.ExternalPlanID.TierFromRaw - >) -)] -public sealed record class Tier : JsonModel -{ /// - /// Amount per unit + /// The event property used to group usage before applying allocations /// - 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 lower bound for this tier + /// The amount to charge for each unit outside of the allocation /// - 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.CumulativeAllocation; + _ = this.GroupAllocation; + _ = this.GroupingKey; _ = this.UnitAmount; - _ = this.TierLowerBound; } - public Tier() { } + public CumulativeGroupedAllocationConfig() { } - public Tier(global::Orb.Models.Beta.ExternalPlanID.Tier tier) - : base(tier) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationConfig( + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + ) + : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 - public Tier(IReadOnlyDictionary rawData) + public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - Tier(FrozenDictionary rawData) + CumulativeGroupedAllocationConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } } -class TierFromRaw : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Tier FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) - { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.Cadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.Cadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.Cadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.Cadence)(-1), - }; - } - - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.Cadence value, - JsonSerializerOptions options - ) - { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.ExternalPlanID.Cadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.Cadence.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.Cadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.Cadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); - } + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfigConverter))] -public record class ConversionRateConfig : ModelBase +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4389,19 +7730,25 @@ public JsonElement Json } } - public ConversionRateConfig(SharedUnitConversionRateConfig value, JsonElement? element = null) + public CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(SharedTieredConversionRateConfig value, JsonElement? element = null) + public CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -4410,7 +7757,7 @@ public ConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4431,7 +7778,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -4451,7 +7798,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -4462,8 +7809,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4483,7 +7830,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of ConversionRateConfig" + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" ); } } @@ -4492,7 +7839,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -4503,8 +7850,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4519,16 +7866,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 CumulativeGroupedAllocationConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4547,16 +7894,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 CumulativeGroupedAllocationConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4564,13 +7911,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 CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4599,12 +7959,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4621,12 +7979,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4635,14 +7991,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig(element); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -4650,32 +8006,39 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationFromRaw - >) -)] -public sealed record class TieredWithProration : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } + /// + /// 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. /// @@ -4715,21 +8078,6 @@ public required string Name init { this._rawData.Set("name", value); } } - /// - /// Configuration for tiered_with_proration pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.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. /// @@ -4789,12 +8137,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? ConversionRateConfig + public DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4885,6 +8233,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4924,18 +8285,18 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("tiered_with_proration") + JsonSerializer.SerializeToElement("daily_credit_allowance") ) ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.TieredWithProrationConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -4947,37 +8308,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public TieredWithProration() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public TieredWithProration( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProration tieredWithProration - ) - : base(tieredWithProration) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public TieredWithProration(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProration(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4985,20 +8348,19 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw - : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProration FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProration.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadenceConverter))] -public enum TieredWithProrationCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -5008,10 +8370,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5019,29 +8380,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Beta - .ExternalPlanID - .TieredWithProrationCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb - .Models - .Beta - .ExternalPlanID - .TieredWithProrationCadence - .Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence)(-1), + "annual" => 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.TieredWithProrationCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -5049,18 +8400,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Annual => - "annual", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Monthly => - "monthly", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Quarterly => - "quarterly", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.OneTime => - "one_time", - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationCadence.Custom => - "custom", + 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)) ), @@ -5071,119 +8416,171 @@ JsonSerializerOptions options } /// -/// Configuration for tiered_with_proration pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class TieredWithProrationConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// Tiers for rating based on total usage quantities into the specified tier - /// with proration + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required IReadOnlyList Tiers + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + 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< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + 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>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); } } /// public override void Validate() { - foreach (var item in this.Tiers) + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) { item.Validate(); } } - public TieredWithProrationConfig() { } + public DailyCreditAllowanceConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig tieredWithProrationConfig - ) - : base(tieredWithProrationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public TieredWithProrationConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - TieredWithProrationConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers + /// + public static DailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) - : this() { - this.Tiers = tiers; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class DailyCreditAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig FromRawUnchecked( + public DailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceConfig.FromRawUnchecked(rawData); } /// -/// Configuration for a single tiered with proration tier +/// Per-dimension credit price for the daily credit allowance model. /// -[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 MatrixValue : JsonModel { /// - /// Inclusive tier starting value + /// 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 TierLowerBound + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("tier_lower_bound"); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + this._rawData.Set>( + "dimension_values", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("tier_lower_bound", value); } } /// - /// Amount per unit + /// Credits charged per unit of usage matching the specified dimension_values /// public required string UnitAmount { @@ -5198,55 +8595,47 @@ public required string UnitAmount /// public override void Validate() { - _ = this.TierLowerBound; + _ = this.DimensionValues; _ = this.UnitAmount; } - public TieredWithProrationConfigTier() { } + public MatrixValue() { } - public TieredWithProrationConfigTier( - global::Orb.Models.Beta.ExternalPlanID.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 global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class MatrixValueFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConfigTier.FromRawUnchecked( - rawData - ); + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfigConverter) -)] -public record class TieredWithProrationConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5263,7 +8652,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5272,7 +8661,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5281,7 +8670,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5290,7 +8679,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 +8700,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8720,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8731,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5363,7 +8752,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of TieredWithProrationConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -5372,7 +8761,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8772,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5399,16 +8788,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -5427,18 +8816,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5446,13 +8833,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5481,12 +8881,10 @@ JsonSerializerOptions 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 +8901,10 @@ JsonSerializerOptions 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 +8913,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig( - element - ); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.TieredWithProrationConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -5534,61 +8928,50 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholds : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : 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 - > - >("cadence"); + return this._rawData.GetNotNullClass>( + "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 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); } } /// @@ -5676,12 +9059,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 MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5772,6 +9155,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9207,12 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.GroupedWithMinMaxThresholdsConfig.Validate(); _ = this.ItemID; + this.MeteredAllowanceConfig.Validate(); if ( !JsonElement.DeepEquals( this.ModelType, - JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds") + JsonSerializer.SerializeToElement("metered_allowance") ) ) { @@ -5834,37 +9230,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public GroupedWithMinMaxThresholds() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) - : base(groupedWithMinMaxThresholds) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholds(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5872,25 +9270,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholds.FromRawUnchecked( - rawData - ); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadenceConverter) -)] -public enum GroupedWithMinMaxThresholdsCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -5900,10 +9291,9 @@ public enum GroupedWithMinMaxThresholdsCadence Custom, } -sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5911,49 +9301,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" => 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.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -5961,26 +9321,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", + 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)) ), @@ -5991,18 +9337,44 @@ JsonSerializerOptions options } /// -/// Configuration for grouped_with_min_max_thresholds pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfigFromRaw - >) -)] -public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// The event property used to group before applying thresholds + /// 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 { @@ -6015,75 +9387,94 @@ public required string GroupingKey } /// - /// The maximum amount to charge each group + /// Per-unit price applied to gross consumption and to the allowance credit. /// - public required string MaximumCharge + public required string UnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("maximum_charge"); + return this._rawData.GetNotNullClass("unit_amount"); } - init { this._rawData.Set("maximum_charge", value); } + init { this._rawData.Set("unit_amount", value); } } /// - /// The minimum amount to charge each group, regardless of usage + /// Sub-line label for the credit row (e.g. 'Up to 3x free egress'). /// - public required string MinimumCharge + public string? AllowanceDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_charge"); + return this._rawData.GetNullableClass("allowance_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("allowance_display_name", value); } - init { this._rawData.Set("minimum_charge", value); } } /// - /// The base price charged per group + /// Sub-line label for the gross consumption row (e.g. 'bytes gotten'). /// - public required string PerUnitRate + public string? ConsumptionDisplayName { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("per_unit_rate"); + return this._rawData.GetNullableClass("consumption_display_name"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("consumption_display_name", value); } - init { this._rawData.Set("per_unit_rate", value); } } /// public override void Validate() { + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; _ = this.GroupingKey; - _ = this.MaximumCharge; - _ = this.MinimumCharge; - _ = this.PerUnitRate; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public GroupedWithMinMaxThresholdsConfig() { } + public MeteredAllowanceConfig() { } - public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig - ) - : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 - public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - GroupedWithMinMaxThresholdsConfig(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6091,22 +9482,16 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] -public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6123,7 +9508,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6132,7 +9517,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6141,7 +9526,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6150,7 +9535,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 +9556,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9576,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9587,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6223,7 +9608,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of GroupedWithMinMaxThresholdsConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -6232,7 +9617,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9628,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6259,16 +9644,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6287,18 +9672,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 MeteredAllowanceConversionRateConfig" ); } 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6306,13 +9689,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6341,12 +9737,10 @@ JsonSerializerOptions 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 +9757,10 @@ JsonSerializerOptions 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 +9769,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.GroupedWithMinMaxThresholdsConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -6394,50 +9784,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 Percent : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum< - string, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence - > - >("cadence"); + return this._rawData.GetNotNullClass>("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for cumulative_grouped_allocation pricing - /// - public required global::Orb.Models.Beta.ExternalPlanID.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. /// @@ -6477,6 +9839,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -6536,12 +9911,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6632,6 +10007,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10059,13 @@ 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") - ) - ) + 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(); @@ -6694,63 +10077,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public CumulativeGroupedAllocation() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) - : base(cumulativeGroupedAllocation) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocation(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocation.FromRawUnchecked( - rawData - ); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadenceConverter) -)] -public enum CumulativeGroupedAllocationCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -6760,10 +10136,9 @@ public enum CumulativeGroupedAllocationCadence Custom, } -sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6771,49 +10146,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" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -6821,26 +10166,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", + 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)) ), @@ -6851,122 +10182,74 @@ JsonSerializerOptions options } /// -/// Configuration for cumulative_grouped_allocation pricing +/// Configuration for percent pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfigFromRaw - >) -)] -public sealed record class CumulativeGroupedAllocationConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PercentConfig : JsonModel { /// - /// The overall allocation across all groups - /// - public required string CumulativeAllocation - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("cumulative_allocation"); - } - init { this._rawData.Set("cumulative_allocation", value); } - } - - /// - /// The allocation per individual group - /// - public required string GroupAllocation - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("group_allocation"); - } - init { this._rawData.Set("group_allocation", value); } - } - - /// - /// The event property used to group usage before applying allocations - /// - public required string GroupingKey - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } - } - - /// - /// The amount to charge for each unit outside of the allocation + /// What percent of the component subtotals to charge /// - public required string UnitAmount + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_amount"); + return this._rawData.GetNotNullStruct("percent"); } - init { this._rawData.Set("unit_amount", value); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; - _ = this.UnitAmount; + _ = this.Percent; } - public CumulativeGroupedAllocationConfig() { } + public PercentConfig() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig - ) - : base(cumulativeGroupedAllocationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } + + [SetsRequiredMembers] + public PercentConfig(double percent) + : this() + { + this.Percent = percent; + } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfigConverter) -)] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6983,7 +10266,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6992,7 +10275,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7001,7 +10284,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -7010,7 +10293,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 +10314,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10334,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10345,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7083,7 +10366,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -7092,7 +10375,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10386,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7119,16 +10402,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 PercentConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7147,18 +10430,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 PercentConversionRateConfig" ); } 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7166,13 +10447,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 CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7201,12 +10494,10 @@ JsonSerializerOptions 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 +10514,10 @@ JsonSerializerOptions 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 +10526,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.CumulativeGroupedAllocationConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -7254,55 +10541,46 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Minimum, - global::Orb.Models.Beta.ExternalPlanID.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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); } } /// - /// The id of the item the price will be associated with. + /// Configuration for event_output pricing /// - public required string ItemID + public required EventOutputConfig EventOutputConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass("event_output_config"); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("event_output_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 +10668,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 EventOutputConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7486,6 +10764,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10816,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.EventOutputConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -7543,55 +10839,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public EventOutput() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public Minimum(global::Orb.Models.Beta.ExternalPlanID.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public EventOutput(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + EventOutput(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumFromRaw : IFromRawJson +class EventOutputFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.Minimum FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Minimum.FromRawUnchecked(rawData); + public EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutput.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(EventOutputCadenceConverter))] +public enum EventOutputCadence { Annual, SemiAnnual, @@ -7601,10 +10898,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter - : JsonConverter +sealed class EventOutputCadenceConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumCadence Read( + public override EventOutputCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7612,19 +10908,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" => EventOutputCadence.Annual, + "semi_annual" => EventOutputCadence.SemiAnnual, + "monthly" => EventOutputCadence.Monthly, + "quarterly" => EventOutputCadence.Quarterly, + "one_time" => EventOutputCadence.OneTime, + "custom" => EventOutputCadence.Custom, + _ => (EventOutputCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumCadence value, + EventOutputCadence value, JsonSerializerOptions options ) { @@ -7632,12 +10928,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", + 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)) ), @@ -7648,77 +10944,84 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for event_output pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.MinimumConfig, - global::Orb.Models.Beta.ExternalPlanID.MinimumConfigFromRaw - >) -)] -public sealed record class MinimumConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class EventOutputConfig : JsonModel { /// - /// The minimum amount to apply + /// The key in the event data to extract the unit rate from. /// - public required string MinimumAmount + public required string UnitRatingKey { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("unit_rating_key"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("unit_rating_key", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// 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 bool? Prorated + public string? DefaultUnitRate { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNullableClass("default_unit_rate"); } - init - { - if (value == null) - { - return; - } + init { this._rawData.Set("default_unit_rate", value); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.UnitRatingKey; + _ = this.DefaultUnitRate; + _ = this.GroupingKey; } - public MinimumConfig() { } + public EventOutputConfig() { } - public MinimumConfig(global::Orb.Models.Beta.ExternalPlanID.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutputConfig(EventOutputConfig eventOutputConfig) + : base(eventOutputConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public EventOutputConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + EventOutputConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( + /// + public static EventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7726,23 +11029,22 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) + public EventOutputConfig(string unitRatingKey) : this() { - this.MinimumAmount = minimumAmount; + this.UnitRatingKey = unitRatingKey; } } -class MinimumConfigFromRaw : IFromRawJson +class EventOutputConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.MinimumConfig.FromRawUnchecked(rawData); + public EventOutputConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + EventOutputConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(EventOutputConversionRateConfigConverter))] +public record class EventOutputConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7759,7 +11061,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public EventOutputConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7768,7 +11070,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public EventOutputConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7777,7 +11079,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public EventOutputConversionRateConfig(JsonElement element) { this._element = element; } @@ -7786,7 +11088,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 +11109,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +11129,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +11140,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7859,7 +11161,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of EventOutputConversionRateConfig" ); } } @@ -7868,7 +11170,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11181,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7895,16 +11197,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 EventOutputConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( + public static implicit operator EventOutputConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7923,32 +11225,43 @@ 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 EventOutputConversionRateConfig" ); } 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(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(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 MinimumConversionRateConfigConverter - : JsonConverter +sealed class EventOutputConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig? Read( + public override EventOutputConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7977,12 +11290,10 @@ JsonSerializerOptions 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 +11310,10 @@ JsonSerializerOptions 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 +11322,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig( - element - ); + return new EventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.MinimumConversionRateConfig value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -8030,473 +11337,256 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.Percent, - global::Orb.Models.Beta.ExternalPlanID.PercentFromRaw - >) -)] -public sealed record class Percent : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel { /// - /// The cadence to bill for this price on. - /// - public required ApiEnum Cadence - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); - } - init { this._rawData.Set("cadence", value); } - } - - /// - /// The id of the item the price will be associated with. - /// - public required string ItemID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); - } - init { this._rawData.Set("item_id", value); } - } - - /// - /// The pricing model type - /// - public JsonElement ModelType - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); - } - init { this._rawData.Set("model_type", value); } - } - - /// - /// The name of the price. - /// - public required string Name - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("name"); - } - init { this._rawData.Set("name", value); } - } - - /// - /// Configuration for percent pricing - /// - public required global::Orb.Models.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. - /// - public string? BillableMetricID - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("billable_metric_id"); - } - init { this._rawData.Set("billable_metric_id", value); } - } - - /// - /// If 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 adjustment to remove from on the plan. /// - public bool? BilledInAdvance + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("billed_in_advance"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("billed_in_advance", value); } + init { this._rawData.Set("adjustment_id", value); } } /// - /// For custom cadence: specifies the duration of the billing period in days - /// or months. + /// The phase to remove this adjustment from. /// - public NewBillingCycleConfiguration? BillingCycleConfiguration + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "billing_cycle_configuration" - ); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("billing_cycle_configuration", value); } + init { this._rawData.Set("plan_phase_order", value); } } - /// - /// The per unit conversion rate of the price currency to the invoicing currency. - /// - public double? ConversionRate + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("conversion_rate"); - } - init { this._rawData.Set("conversion_rate", value); } + _ = this.AdjustmentID; + _ = this.PlanPhaseOrder; } - /// - /// The configuration for the rate of the price currency to the invoicing currency. - /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? ConversionRateConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "conversion_rate_config" - ); - } - init { this._rawData.Set("conversion_rate_config", value); } - } + public RemoveAdjustment() { } - /// - /// An ISO 4217 currency string, or custom pricing unit identifier, in which - /// this price is billed. - /// - public string? Currency - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("currency"); - } - init { this._rawData.Set("currency", value); } - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 - /// - /// For dimensional price: specifies a price group and dimension values - /// - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "dimensional_price_configuration" - ); - } - init { this._rawData.Set("dimensional_price_configuration", value); } + this._rawData = new(rawData); } - /// - /// An alias for the price. - /// - public string? ExternalPriceID +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// If the Price represents a fixed cost, this represents the quantity of units applied. - /// - public double? FixedPriceQuantity + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - /// - /// The property used to group this price on an invoice - /// - public string? InvoiceGroupingKey + [SetsRequiredMembers] + public RemoveAdjustment(string adjustmentID) + : this() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("invoice_grouping_key"); - } - init { this._rawData.Set("invoice_grouping_key", value); } + this.AdjustmentID = adjustmentID; } +} - /// - /// Within each billing cycle, specifies the cadence at which invoices are produced. - /// If unspecified, a single invoice is produced per billing cycle. - /// - public NewBillingCycleConfiguration? InvoicingCycleConfiguration - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "invoicing_cycle_configuration" - ); - } - init { this._rawData.Set("invoicing_cycle_configuration", value); } - } +class RemoveAdjustmentFromRaw : IFromRawJson +{ + /// + public RemoveAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + RemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemovePrice : JsonModel +{ /// - /// User-specified key/value pairs for the resource. Individual keys can be removed - /// by setting the value to `null`, and the entire metadata mapping can be cleared - /// by setting `metadata` to `null`. + /// The id of the price to remove from the plan. /// - public IReadOnlyDictionary? Metadata + public required string PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass>("metadata"); - } - init - { - this._rawData.Set?>( - "metadata", - value == null ? null : FrozenDictionary.ToFrozenDictionary(value) - ); + return this._rawData.GetNotNullClass("price_id"); } + init { this._rawData.Set("price_id", value); } } /// - /// A transient ID that can be used to reference this price when adding adjustments - /// in the same API call. + /// The phase to remove this price from. /// - public string? ReferenceID + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("reference_id"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("reference_id", value); } + init { this._rawData.Set("plan_phase_order", value); } } /// public override void Validate() { - this.Cadence.Validate(); - _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } - _ = this.Name; - this.PercentConfig.Validate(); - _ = this.BillableMetricID; - _ = this.BilledInAdvance; - this.BillingCycleConfiguration?.Validate(); - _ = this.ConversionRate; - this.ConversionRateConfig?.Validate(); - _ = this.Currency; - this.DimensionalPriceConfiguration?.Validate(); - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.InvoiceGroupingKey; - this.InvoicingCycleConfiguration?.Validate(); - _ = this.Metadata; - _ = this.ReferenceID; + _ = this.PriceID; + _ = this.PlanPhaseOrder; } - public Percent() - { - this.ModelType = JsonSerializer.SerializeToElement("percent"); - } + public RemovePrice() { } - public Percent(global::Orb.Models.Beta.ExternalPlanID.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public RemovePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + RemovePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } -} -class PercentFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.Percent.FromRawUnchecked(rawData); + [SetsRequiredMembers] + public RemovePrice(string priceID) + : this() + { + this.PriceID = priceID; + } } -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentCadenceConverter))] -public enum PercentCadence +class RemovePriceFromRaw : IFromRawJson { - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, + /// + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); } -sealed class PercentCadenceConverter - : JsonConverter +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel { - public override global::Orb.Models.Beta.ExternalPlanID.PercentCadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// The definition of a new adjustment to create and add to the plan. + /// + public required ReplaceAdjustmentAdjustment Adjustment { - return JsonSerializer.Deserialize(ref reader, options) switch + get { - "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), - }; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("adjustment"); + } + init { this._rawData.Set("adjustment", value); } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentCadence value, - JsonSerializerOptions options - ) + /// + /// The id of the adjustment on the plan to replace in the plan. + /// + public required string ReplacesAdjustmentID { - JsonSerializer.Serialize( - 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", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); + } + init { this._rawData.Set("replaces_adjustment_id", value); } } -} -/// -/// Configuration for percent pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.PercentConfig, - global::Orb.Models.Beta.ExternalPlanID.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel -{ /// - /// What percent of the component subtotals to charge + /// The phase to replace this adjustment from. /// - public required double Percent + public long? PlanPhaseOrder { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + return this._rawData.GetNullableStruct("plan_phase_order"); } - init { this._rawData.Set("percent", value); } + init { this._rawData.Set("plan_phase_order", value); } } /// public override void Validate() { - _ = this.Percent; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; + _ = this.PlanPhaseOrder; } - public PercentConfig() { } + public ReplaceAdjustment() { } - public PercentConfig(global::Orb.Models.Beta.ExternalPlanID.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) + : base(replaceAdjustment) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public ReplaceAdjustment(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + ReplaceAdjustment(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( + /// + public static ReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class ReplaceAdjustmentFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.PercentConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.PercentConfig.FromRawUnchecked(rawData); + public ReplaceAdjustment FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplaceAdjustment.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +/// +/// 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; @@ -8513,75 +11603,178 @@ public JsonElement Json } } - public PercentConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + 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 PercentConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { this.Value = value; this._element = element; } - public PercentConversionRateConfig(JsonElement 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) { - this._element = element; + value = this.Value as NewAmountDiscount; + return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - value = this.Value as SharedUnitConversionRateConfig; + value = this.Value as NewMinimum; return value != null; } /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - value = this.Value as SharedTieredConversionRateConfig; + value = this.Value as NewMaximum; return value != null; } /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -8592,28 +11785,43 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public void Switch( - System::Action unit, - System::Action tiered + System::Action newPercentageDiscount, + System::Action newUsageDiscount, + System::Action newAmountDiscount, + System::Action newMinimum, + System::Action newMaximum ) { switch (this.Value) { - case SharedUnitConversionRateConfig value: - unit(value); + case NewPercentageDiscount value: + newPercentageDiscount(value); break; - case SharedTieredConversionRateConfig value: - tiered(value); + case NewUsageDiscount value: + newUsageDiscount(value); + break; + case NewAmountDiscount value: + newAmountDiscount(value); + break; + case NewMinimum value: + newMinimum(value); + break; + case NewMaximum value: + newMaximum(value); break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ); } } @@ -8622,7 +11830,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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,34 +11841,48 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// /// public T Match( - System::Func unit, - System::Func tiered + System::Func newPercentageDiscount, + System::Func newUsageDiscount, + System::Func newAmountDiscount, + System::Func newMinimum, + System::Func newMaximum ) { return this.Value switch { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), + NewPercentageDiscount value => newPercentageDiscount(value), + NewUsageDiscount value => newUsageDiscount(value), + NewAmountDiscount value => newAmountDiscount(value), + NewMinimum value => newMinimum(value), + NewMaximum value => newMaximum(value), _ => throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of ReplaceAdjustmentAdjustment" ), }; } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - SharedTieredConversionRateConfig value - ) => new(value); + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); + + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -8677,18 +11899,22 @@ 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 ReplaceAdjustmentAdjustment" ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8696,157 +11922,352 @@ public override int GetHashCode() } 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 PercentConversionRateConfigConverter - : JsonConverter +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter { - public override global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig? Read( + public override ReplaceAdjustmentAdjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; + string? adjustmentType; try { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + adjustmentType = element.GetProperty("adjustment_type").GetString(); } catch { - conversionRateType = null; + adjustmentType = null; } - switch (conversionRateType) + switch (adjustmentType) { - case "unit": + case "percentage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "tiered": + case "usage_discount": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "maximum": + { + try + { + var deserialized = JsonSerializer.Deserialize(element, options); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) { // ignore } - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig( - element - ); - } - } + 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); } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.PercentConversionRateConfig value, - JsonSerializerOptions options - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePrice(FrozenDictionary rawData) { - JsonSerializer.Serialize(writer, value.Json, options); + 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< - global::Orb.Models.Beta.ExternalPlanID.EventOutput, - global::Orb.Models.Beta.ExternalPlanID.EventOutputFromRaw + ReplacePriceLicenseAllocationPrice, + ReplacePriceLicenseAllocationPriceFromRaw >) )] -public sealed record class EventOutput : JsonModel +public sealed record class ReplacePriceLicenseAllocationPrice : 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 + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// Configuration for event_output pricing + /// The id of the item the price will be associated with. /// - public required global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig EventOutputConfig + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("event_output_config", value); } + init { this._rawData.Set("item_id", value); } } /// - /// The id of the item the price will be associated with. + /// License allocations to associate with this price. Each entry defines a per-license + /// credit pool granted each cadence. Requires license_type_id or license_type_configuration + /// to be set. /// - public required string ItemID + public required IReadOnlyList LicenseAllocations { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("license_allocations"); + } + init + { + this._rawData.Set>( + "license_allocations", + ImmutableArray.ToImmutableArray(value) + ); } - init { this._rawData.Set("item_id", value); } } /// /// The pricing model type /// - public JsonElement ModelType + public required ApiEnum ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass< + ApiEnum + >("model_type"); } init { this._rawData.Set("model_type", value); } } @@ -8864,6 +12285,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for unit pricing + /// + public required UnitConfig UnitConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_config"); + } + init { this._rawData.Set("unit_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -8923,12 +12357,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 ReplacePriceLicenseAllocationPriceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9019,6 +12453,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -9058,18 +12505,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + foreach (var item in this.LicenseAllocations) { - throw new OrbInvalidDataException("Invalid value given for constant"); + item.Validate(); } + this.ModelType.Validate(); _ = this.Name; + this.UnitConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -9081,35 +12524,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() - { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); - } + public ReplacePriceLicenseAllocationPrice() { } - public EventOutput(global::Orb.Models.Beta.ExternalPlanID.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePriceLicenseAllocationPrice( + ReplacePriceLicenseAllocationPrice replacePriceLicenseAllocationPrice + ) + : base(replacePriceLicenseAllocationPrice) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public ReplacePriceLicenseAllocationPrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - - this.ModelType = JsonSerializer.SerializeToElement("event_output"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + ReplacePriceLicenseAllocationPrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + /// + public static ReplacePriceLicenseAllocationPrice FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9117,19 +12561,19 @@ IReadOnlyDictionary rawData } } -class EventOutputFromRaw : IFromRawJson +class ReplacePriceLicenseAllocationPriceFromRaw : IFromRawJson { /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutput FromRawUnchecked( + public ReplacePriceLicenseAllocationPrice FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutput.FromRawUnchecked(rawData); + ) => ReplacePriceLicenseAllocationPrice.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(ReplacePriceLicenseAllocationPriceCadenceConverter))] +public enum ReplacePriceLicenseAllocationPriceCadence { Annual, SemiAnnual, @@ -9139,163 +12583,496 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +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 global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence Read( + public override ReplacePriceLicenseAllocationPriceModelType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options ) { - return JsonSerializer.Deserialize(ref reader, options) switch - { - "annual" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Annual, - "semi_annual" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.SemiAnnual, - "monthly" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Monthly, - "quarterly" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Quarterly, - "one_time" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.OneTime, - "custom" => global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Custom, - _ => (global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence)(-1), - }; + 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 override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence value, - JsonSerializerOptions options + public ReplacePriceLicenseAllocationPriceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null ) { - JsonSerializer.Serialize( - writer, - value switch - { - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Annual => "annual", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Monthly => "monthly", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Quarterly => "quarterly", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.OneTime => "one_time", - global::Orb.Models.Beta.ExternalPlanID.EventOutputCadence.Custom => "custom", - _ => throw new OrbInvalidDataException( - string.Format("Invalid value '{0}' in {1}", value, nameof(value)) - ), - }, - options - ); + this.Value = value; + this._element = element; + } + + public ReplacePriceLicenseAllocationPriceConversionRateConfig(JsonElement element) + { + this._element = element; } -} -/// -/// Configuration for event_output pricing -/// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfigFromRaw - >) -)] -public sealed record class EventOutputConfig : JsonModel -{ /// - /// The key in the event data to extract the unit rate from. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// /// - public required string UnitRatingKey + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("unit_rating_key"); - } - init { this._rawData.Set("unit_rating_key", value); } + value = this.Value as SharedUnitConversionRateConfig; + return value != null; } /// - /// If provided, this amount will be used as the unit rate when an event does - /// not have a value for the `unit_rating_key`. If not provided, events missing - /// a unit rate will be ignored. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// /// - public string? DefaultUnitRate + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) { - get + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("default_unit_rate"); + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); } - 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. + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// /// - public string? GroupingKey + public T Match( + System::Func unit, + System::Func tiered + ) { - get + return this.Value switch { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); - } - init { this._rawData.Set("grouping_key", value); } + 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() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePriceLicenseAllocationPriceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public EventOutputConfig() { } + public virtual bool Equals(ReplacePriceLicenseAllocationPriceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public EventOutputConfig( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig eventOutputConfig - ) - : base(eventOutputConfig) { } + public override int GetHashCode() + { + return 0; + } - public EventOutputConfig(IReadOnlyDictionary rawData) + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() { - this._rawData = new(rawData); + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; } +} -#pragma warning disable CS8618 - [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) +sealed class ReplacePriceLicenseAllocationPriceConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePriceLicenseAllocationPriceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - this._rawData = new(rawData); + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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); + } + } } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData + public override void Write( + Utf8JsonWriter writer, + ReplacePriceLicenseAllocationPriceConversionRateConfig value, + JsonSerializerOptions options ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) - : this() - { - this.UnitRatingKey = unitRatingKey; + JsonSerializer.Serialize(writer, value.Json, options); } } -class EventOutputConfigFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.EventOutputConfig.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfigConverter) -)] -public record class EventOutputConversionRateConfig : ModelBase +/// +/// New plan price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase { public object? Value { get; } = null; @@ -9312,3959 +13089,3817 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value, - JsonElement? element = null - ) + public string ItemID { - this.Value = value; - this._element = element; + 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, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newPlanMinimumComposite: (x) => x.ItemID, + percent: (x) => x.ItemID, + eventOutput: (x) => x.ItemID + ); + } } - public EventOutputConversionRateConfig( - SharedTieredConversionRateConfig value, - JsonElement? element = null - ) + public string Name { - this.Value = value; - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.Name, + newPlanTiered: (x) => x.Name, + newPlanBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newPlanPackage: (x) => x.Name, + newPlanMatrix: (x) => x.Name, + newPlanThresholdTotalAmount: (x) => x.Name, + newPlanTieredPackage: (x) => x.Name, + newPlanTieredWithMinimum: (x) => x.Name, + newPlanGroupedTiered: (x) => x.Name, + newPlanTieredPackageWithMinimum: (x) => x.Name, + newPlanPackageWithAllocation: (x) => x.Name, + newPlanUnitWithPercent: (x) => x.Name, + newPlanMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newPlanUnitWithProration: (x) => x.Name, + newPlanGroupedAllocation: (x) => x.Name, + newPlanBulkWithProration: (x) => x.Name, + newPlanGroupedWithProratedMinimum: (x) => x.Name, + newPlanGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newPlanMatrixWithDisplayName: (x) => x.Name, + newPlanGroupedTieredPackage: (x) => x.Name, + newPlanMaxGroupTieredPackage: (x) => x.Name, + newPlanScalableMatrixWithUnitPricing: (x) => x.Name, + newPlanScalableMatrixWithTieredPricing: (x) => x.Name, + newPlanCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newPlanMinimumComposite: (x) => x.Name, + percent: (x) => x.Name, + eventOutput: (x) => x.Name + ); + } } - public EventOutputConversionRateConfig(JsonElement element) + public string? BillableMetricID { - this._element = element; + get + { + return Match( + newPlanUnit: (x) => x.BillableMetricID, + newPlanTiered: (x) => x.BillableMetricID, + newPlanBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newPlanPackage: (x) => x.BillableMetricID, + newPlanMatrix: (x) => x.BillableMetricID, + newPlanThresholdTotalAmount: (x) => x.BillableMetricID, + newPlanTieredPackage: (x) => x.BillableMetricID, + newPlanTieredWithMinimum: (x) => x.BillableMetricID, + newPlanGroupedTiered: (x) => x.BillableMetricID, + newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, + newPlanPackageWithAllocation: (x) => x.BillableMetricID, + newPlanUnitWithPercent: (x) => x.BillableMetricID, + newPlanMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newPlanUnitWithProration: (x) => x.BillableMetricID, + newPlanGroupedAllocation: (x) => x.BillableMetricID, + newPlanBulkWithProration: (x) => x.BillableMetricID, + newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, + newPlanGroupedTieredPackage: (x) => x.BillableMetricID, + newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, + newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + 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.TryPickUnit(out var value)) { - /// // `value` is of type `SharedUnitConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + public bool? BilledInAdvance { - value = this.Value as SharedUnitConversionRateConfig; - 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, + 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, + 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, + 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.TryPickTiered(out var value)) { - /// // `value` is of type `SharedTieredConversionRateConfig` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + public string? Currency { - value = this.Value as SharedTieredConversionRateConfig; - 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, + 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 + ); + } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action unit, - System::Action tiered - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - 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 EventOutputConversionRateConfig" - ); + 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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); } } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} - /// ); - /// - /// - /// - public T Match( - System::Func unit, - System::Func tiered - ) + public string? ExternalPriceID { - return this.Value switch + get { - SharedUnitConversionRateConfig value => unit(value), - SharedTieredConversionRateConfig value => tiered(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" - ), - }; + 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, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newPlanMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig( - SharedUnitConversionRateConfig value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.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() + public double? FixedPriceQuantity { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + 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, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newPlanMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity ); } - this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? other - ) + public string? InvoiceGroupingKey { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + 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, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newPlanMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - public override int GetHashCode() + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - return 0; + 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, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newPlanMinimumComposite: (x) => x.InvoicingCycleConfiguration, + percent: (x) => x.InvoicingCycleConfiguration, + eventOutput: (x) => x.InvoicingCycleConfiguration + ); + } } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class EventOutputConversionRateConfigConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + public string? LicenseTypeID { - var element = JsonSerializer.Deserialize(ref reader, options); - string? conversionRateType; - try - { - conversionRateType = element.GetProperty("conversion_rate_type").GetString(); - } - catch + get { - conversionRateType = null; + return Match( + newPlanUnit: (x) => x.LicenseTypeID, + newPlanTiered: (x) => x.LicenseTypeID, + newPlanBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newPlanPackage: (x) => x.LicenseTypeID, + newPlanMatrix: (x) => x.LicenseTypeID, + newPlanThresholdTotalAmount: (x) => x.LicenseTypeID, + newPlanTieredPackage: (x) => x.LicenseTypeID, + newPlanTieredWithMinimum: (x) => x.LicenseTypeID, + newPlanGroupedTiered: (x) => x.LicenseTypeID, + newPlanTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newPlanPackageWithAllocation: (x) => x.LicenseTypeID, + newPlanUnitWithPercent: (x) => x.LicenseTypeID, + newPlanMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newPlanUnitWithProration: (x) => x.LicenseTypeID, + newPlanGroupedAllocation: (x) => x.LicenseTypeID, + newPlanBulkWithProration: (x) => x.LicenseTypeID, + newPlanGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newPlanGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newPlanMatrixWithDisplayName: (x) => x.LicenseTypeID, + newPlanGroupedTieredPackage: (x) => x.LicenseTypeID, + newPlanMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newPlanScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newPlanCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newPlanMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); } + } - switch (conversionRateType) + public string? ReferenceID + { + 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.ExternalPlanID.EventOutputConversionRateConfig( - element - ); - } + 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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newPlanMinimumComposite: (x) => x.ReferenceID, + percent: (x) => x.ReferenceID, + eventOutput: (x) => x.ReferenceID + ); } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.EventOutputConversionRateConfig value, - JsonSerializerOptions options - ) + public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) { - JsonSerializer.Serialize(writer, value.Json, options); + this.Value = value; + this._element = element; } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment, - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustmentFromRaw - >) -)] -public sealed record class RemoveAdjustment : JsonModel -{ - /// - /// The id of the adjustment to remove from on the plan. - /// - public required string AdjustmentID + public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); - } - init { this._rawData.Set("adjustment_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to remove this adjustment from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { - _ = this.AdjustmentID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public RemoveAdjustment() { } - - public RemoveAdjustment( - global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment removeAdjustment - ) - : base(removeAdjustment) { } + public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public RemoveAdjustment(IReadOnlyDictionary rawData) + public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() + public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) { - this.AdjustmentID = adjustmentID; + this.Value = value; + this._element = element; } -} -class RemoveAdjustmentFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemoveAdjustment.FromRawUnchecked(rawData); -} - -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.RemovePrice, - global::Orb.Models.Beta.ExternalPlanID.RemovePriceFromRaw - >) -)] -public sealed record class RemovePrice : JsonModel -{ - /// - /// The id of the price to remove from the plan. - /// - public required string PriceID + public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("price_id"); - } - init { this._rawData.Set("price_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to remove this price from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice( + NewPlanTieredPackageWithMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) { - _ = this.PriceID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public RemovePrice() { } - - public RemovePrice(global::Orb.Models.Beta.ExternalPlanID.RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) + public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData + public ReplacePricePrice( + ReplacePricePriceTieredWithProration value, + JsonElement? element = null ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } - [SetsRequiredMembers] - public RemovePrice(string priceID) - : this() + public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) { - this.PriceID = priceID; + this.Value = value; + this._element = element; } -} - -class RemovePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.RemovePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.RemovePrice.FromRawUnchecked(rawData); -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentFromRaw - >) -)] -public sealed record class ReplaceAdjustment : JsonModel -{ - /// - /// The definition of a new adjustment to create and add to the plan. - /// - public required global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment Adjustment + public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); - } - init { this._rawData.Set("adjustment", value); } + this.Value = value; + this._element = element; } - /// - /// The id of the adjustment on the plan to replace in the plan. - /// - public required string ReplacesAdjustmentID + public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); - } - init { this._rawData.Set("replaces_adjustment_id", value); } + this.Value = value; + this._element = element; } - /// - /// The phase to replace this adjustment from. - /// - public long? PlanPhaseOrder + public ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value, + JsonElement? element = null + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + this.Value = value; + this._element = element; } - /// - public override void Validate() + public ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value, + JsonElement? element = null + ) { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; - _ = this.PlanPhaseOrder; + this.Value = value; + this._element = element; } - public ReplaceAdjustment() { } - - public ReplaceAdjustment( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment replaceAdjustment + public ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value, + JsonElement? element = null ) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(IReadOnlyDictionary rawData) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning disable CS8618 - [SetsRequiredMembers] - ReplaceAdjustment(FrozenDictionary rawData) + public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) { - this._rawData = new(rawData); + this.Value = value; + this._element = element; } -#pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + this.Value = value; + this._element = element; } -} - -class ReplaceAdjustmentFromRaw - : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustment.FromRawUnchecked(rawData); -} - -/// -/// The definition of a new adjustment to create and add to the plan. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustmentConverter))] -public record class ReplaceAdjustmentAdjustment : ModelBase -{ - public object? Value { get; } = null; - JsonElement? _element = null; + public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) + { + this.Value = value; + this._element = element; + } - public JsonElement Json + public ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value, + JsonElement? element = null + ) { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); - } + this.Value = value; + this._element = element; } - public string? Currency + public ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value, + JsonElement? element = null + ) { - get - { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency - ); - } + this.Value = value; + this._element = element; } - public bool? IsInvoiceLevel + public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) { - get - { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel - ); - } + this.Value = value; + this._element = element; + } + + public ReplacePricePrice( + ReplacePricePriceCumulativeGroupedAllocation value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; } - public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) + public ReplacePricePrice( + ReplacePricePriceDailyCreditAllowance value, + JsonElement? element = null + ) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) + public ReplacePricePrice(ReplacePricePriceMeteredAllowance value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) + public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) + public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) { this.Value = value; this._element = element; } - public ReplaceAdjustmentAdjustment(JsonElement 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 . + /// 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.TryPickNewPlanUnit(out var value)) { + /// // `value` is of type `NewPlanUnitPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public bool TryPickNewPlanUnit([NotNullWhen(true)] out NewPlanUnitPrice? value) { - value = this.Value as NewPercentageDiscount; + 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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` + /// if (instance.TryPickNewPlanTiered(out var value)) { + /// // `value` is of type `NewPlanTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public bool TryPickNewPlanTiered([NotNullWhen(true)] out NewPlanTieredPrice? value) { - value = this.Value as NewUsageDiscount; + 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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` + /// if (instance.TryPickNewPlanBulk(out var value)) { + /// // `value` is of type `NewPlanBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public bool TryPickNewPlanBulk([NotNullWhen(true)] out NewPlanBulkPrice? value) { - value = this.Value as NewAmountDiscount; + 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 . + /// 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.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value + ) { - value = this.Value as NewMinimum; + 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 . + /// 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.TryPickNewPlanPackage(out var value)) { + /// // `value` is of type `NewPlanPackagePrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) { - value = this.Value as NewMaximum; + value = this.Value as NewPlanPackagePrice; 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.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. /// /// /// - /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); + /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewPlanThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } /// /// /// - public void Switch( - System::Action newPercentageDiscount, - System::Action newUsageDiscount, - System::Action newAmountDiscount, - System::Action newMinimum, - System::Action newMaximum + public bool TryPickNewPlanThresholdTotalAmount( + [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value ) { - 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" - ); - } + 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; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. + /// 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. /// /// /// - /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} - /// ); + /// if (instance.TryPickNewPlanMatrixWithAllocation(out var value)) { + /// // `value` is of type `NewPlanMatrixWithAllocationPrice` + /// Console.WriteLine(value); + /// } /// /// /// - public T Match( - System::Func newPercentageDiscount, - System::Func newUsageDiscount, - System::Func newAmountDiscount, - System::Func newMinimum, - System::Func newMaximum + public bool TryPickNewPlanMatrixWithAllocation( + [NotNullWhen(true)] out NewPlanMatrixWithAllocationPrice? value ) { - 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" - ), - }; + value = this.Value as NewPlanMatrixWithAllocationPrice; + return value != null; } - 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 - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.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). + /// 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.TryPickTieredWithProration(out var value)) { + /// // `value` is of type `ReplacePricePriceTieredWithProration` + /// Console.WriteLine(value); + /// } + /// + /// /// - 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( - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? other + public bool TryPickTieredWithProration( + [NotNullWhen(true)] out ReplacePricePriceTieredWithProration? value ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + value = this.Value as ReplacePricePriceTieredWithProration; + 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.TryPickNewPlanUnitWithProration(out var value)) { + /// // `value` is of type `NewPlanUnitWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanUnitWithProration( + [NotNullWhen(true)] out NewPlanUnitWithProrationPrice? value + ) { - return 0; + value = this.Value as NewPlanUnitWithProrationPrice; + return value != null; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); -} - -sealed class ReplaceAdjustmentAdjustmentConverter - : JsonConverter -{ - public override global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment? 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.TryPickNewPlanGroupedAllocation(out var value)) { + /// // `value` is of type `NewPlanGroupedAllocationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedAllocation( + [NotNullWhen(true)] out NewPlanGroupedAllocationPrice? value ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? adjustmentType; - try - { - adjustmentType = element.GetProperty("adjustment_type").GetString(); - } - catch - { - adjustmentType = null; - } - - switch (adjustmentType) - { - case "percentage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "usage_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "amount_discount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment( - element - ); - } - } + value = this.Value as NewPlanGroupedAllocationPrice; + return value != null; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplaceAdjustmentAdjustment 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.TryPickNewPlanBulkWithProration(out var value)) { + /// // `value` is of type `NewPlanBulkWithProrationPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanBulkWithProration( + [NotNullWhen(true)] out NewPlanBulkWithProrationPrice? value ) { - JsonSerializer.Serialize(writer, value.Json, options); + value = this.Value as NewPlanBulkWithProrationPrice; + return value != null; } -} -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Beta.ExternalPlanID.ReplacePrice, - global::Orb.Models.Beta.ExternalPlanID.ReplacePriceFromRaw - >) -)] -public sealed record class ReplacePrice : JsonModel -{ /// - /// The id of the price on the plan to replace in the plan. + /// Returns true and sets the 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 required string ReplacesPriceID + public bool TryPickNewPlanGroupedWithProratedMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithProratedMinimumPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + value = this.Value as NewPlanGroupedWithProratedMinimumPrice; + return value != null; } /// - /// The allocation price to add to the plan. + /// Returns true and sets the 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 NewAllocationPrice? AllocationPrice + public bool TryPickNewPlanGroupedWithMeteredMinimum( + [NotNullWhen(true)] out NewPlanGroupedWithMeteredMinimumPrice? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + value = this.Value as NewPlanGroupedWithMeteredMinimumPrice; + return value != null; } /// - /// The phase to replace this price from. + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickGroupedWithMinMaxThresholds(out var value)) { + /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` + /// Console.WriteLine(value); + /// } + /// + /// /// - public long? PlanPhaseOrder + public bool TryPickGroupedWithMinMaxThresholds( + [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("plan_phase_order"); - } - init { this._rawData.Set("plan_phase_order", value); } + value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; + return value != null; } /// - /// New plan price request body params. + /// Returns true and sets the 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 global::Orb.Models.Beta.ExternalPlanID.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(global::Orb.Models.Beta.ExternalPlanID.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 global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData + public bool TryPickNewPlanMatrixWithDisplayName( + [NotNullWhen(true)] out NewPlanMatrixWithDisplayNamePrice? value ) { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() - { - this.ReplacesPriceID = replacesPriceID; - } -} - -class ReplacePriceFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Beta.ExternalPlanID.ReplacePrice FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Beta.ExternalPlanID.ReplacePrice.FromRawUnchecked(rawData); -} - -/// -/// New plan price request body params. -/// -[JsonConverter(typeof(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase -{ - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - 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 - ); - } + value = this.Value as NewPlanMatrixWithDisplayNamePrice; + return value != null; } - public string Name - { - get - { - return Match( - newPlanUnit: (x) => x.Name, - newPlanTiered: (x) => x.Name, - newPlanBulk: (x) => x.Name, - bulkWithFilters: (x) => x.Name, - newPlanPackage: (x) => x.Name, - newPlanMatrix: (x) => x.Name, - newPlanThresholdTotalAmount: (x) => x.Name, - newPlanTieredPackage: (x) => x.Name, - newPlanTieredWithMinimum: (x) => x.Name, - newPlanGroupedTiered: (x) => x.Name, - newPlanTieredPackageWithMinimum: (x) => x.Name, - newPlanPackageWithAllocation: (x) => x.Name, - newPlanUnitWithPercent: (x) => x.Name, - newPlanMatrixWithAllocation: (x) => x.Name, - tieredWithProration: (x) => x.Name, - newPlanUnitWithProration: (x) => x.Name, - newPlanGroupedAllocation: (x) => x.Name, - newPlanBulkWithProration: (x) => x.Name, - newPlanGroupedWithProratedMinimum: (x) => x.Name, - newPlanGroupedWithMeteredMinimum: (x) => x.Name, - groupedWithMinMaxThresholds: (x) => x.Name, - newPlanMatrixWithDisplayName: (x) => x.Name, - newPlanGroupedTieredPackage: (x) => x.Name, - newPlanMaxGroupTieredPackage: (x) => x.Name, - newPlanScalableMatrixWithUnitPricing: (x) => x.Name, - newPlanScalableMatrixWithTieredPricing: (x) => x.Name, - newPlanCumulativeGroupedBulk: (x) => x.Name, - cumulativeGroupedAllocation: (x) => x.Name, - minimum: (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.TryPickNewPlanGroupedTieredPackage(out var value)) { + /// // `value` is of type `NewPlanGroupedTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanGroupedTieredPackage( + [NotNullWhen(true)] out NewPlanGroupedTieredPackagePrice? value + ) + { + value = this.Value as NewPlanGroupedTieredPackagePrice; + return value != null; } - public string? BillableMetricID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMaxGroupTieredPackage(out var value)) { + /// // `value` is of type `NewPlanMaxGroupTieredPackagePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMaxGroupTieredPackage( + [NotNullWhen(true)] out NewPlanMaxGroupTieredPackagePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BillableMetricID, - newPlanTiered: (x) => x.BillableMetricID, - newPlanBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newPlanPackage: (x) => x.BillableMetricID, - newPlanMatrix: (x) => x.BillableMetricID, - newPlanThresholdTotalAmount: (x) => x.BillableMetricID, - newPlanTieredPackage: (x) => x.BillableMetricID, - newPlanTieredWithMinimum: (x) => x.BillableMetricID, - newPlanGroupedTiered: (x) => x.BillableMetricID, - newPlanTieredPackageWithMinimum: (x) => x.BillableMetricID, - newPlanPackageWithAllocation: (x) => x.BillableMetricID, - newPlanUnitWithPercent: (x) => x.BillableMetricID, - newPlanMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newPlanUnitWithProration: (x) => x.BillableMetricID, - newPlanGroupedAllocation: (x) => x.BillableMetricID, - newPlanBulkWithProration: (x) => x.BillableMetricID, - newPlanGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newPlanGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newPlanMatrixWithDisplayName: (x) => x.BillableMetricID, - newPlanGroupedTieredPackage: (x) => x.BillableMetricID, - newPlanMaxGroupTieredPackage: (x) => x.BillableMetricID, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newPlanCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newPlanMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + value = this.Value as NewPlanMaxGroupTieredPackagePrice; + return value != null; } - public bool? BilledInAdvance + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanScalableMatrixWithUnitPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithUnitPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanScalableMatrixWithUnitPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithUnitPricingPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BilledInAdvance, - newPlanTiered: (x) => x.BilledInAdvance, - newPlanBulk: (x) => x.BilledInAdvance, - bulkWithFilters: (x) => x.BilledInAdvance, - newPlanPackage: (x) => x.BilledInAdvance, - newPlanMatrix: (x) => x.BilledInAdvance, - newPlanThresholdTotalAmount: (x) => x.BilledInAdvance, - newPlanTieredPackage: (x) => x.BilledInAdvance, - newPlanTieredWithMinimum: (x) => x.BilledInAdvance, - newPlanGroupedTiered: (x) => x.BilledInAdvance, - newPlanTieredPackageWithMinimum: (x) => x.BilledInAdvance, - newPlanPackageWithAllocation: (x) => x.BilledInAdvance, - newPlanUnitWithPercent: (x) => x.BilledInAdvance, - newPlanMatrixWithAllocation: (x) => x.BilledInAdvance, - tieredWithProration: (x) => x.BilledInAdvance, - newPlanUnitWithProration: (x) => x.BilledInAdvance, - newPlanGroupedAllocation: (x) => x.BilledInAdvance, - newPlanBulkWithProration: (x) => x.BilledInAdvance, - newPlanGroupedWithProratedMinimum: (x) => x.BilledInAdvance, - newPlanGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, - groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, - newPlanMatrixWithDisplayName: (x) => x.BilledInAdvance, - newPlanGroupedTieredPackage: (x) => x.BilledInAdvance, - newPlanMaxGroupTieredPackage: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, - newPlanScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, - newPlanCumulativeGroupedBulk: (x) => x.BilledInAdvance, - cumulativeGroupedAllocation: (x) => x.BilledInAdvance, - minimum: (x) => x.BilledInAdvance, - newPlanMinimumComposite: (x) => x.BilledInAdvance, - percent: (x) => x.BilledInAdvance, - eventOutput: (x) => x.BilledInAdvance - ); - } + value = this.Value as NewPlanScalableMatrixWithUnitPricingPrice; + return value != null; } - public NewBillingCycleConfiguration? BillingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanScalableMatrixWithTieredPricing(out var value)) { + /// // `value` is of type `NewPlanScalableMatrixWithTieredPricingPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanScalableMatrixWithTieredPricing( + [NotNullWhen(true)] out NewPlanScalableMatrixWithTieredPricingPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.BillingCycleConfiguration, - newPlanTiered: (x) => x.BillingCycleConfiguration, - newPlanBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newPlanPackage: (x) => x.BillingCycleConfiguration, - newPlanMatrix: (x) => x.BillingCycleConfiguration, - newPlanThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newPlanTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedTiered: (x) => x.BillingCycleConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newPlanPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newPlanUnitWithPercent: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newPlanUnitWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedAllocation: (x) => x.BillingCycleConfiguration, - newPlanBulkWithProration: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newPlanMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newPlanGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newPlanMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + value = this.Value as NewPlanScalableMatrixWithTieredPricingPrice; + return value != null; } - public double? ConversionRate + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanCumulativeGroupedBulk(out var value)) { + /// // `value` is of type `NewPlanCumulativeGroupedBulkPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanCumulativeGroupedBulk( + [NotNullWhen(true)] out NewPlanCumulativeGroupedBulkPrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.ConversionRate, - newPlanTiered: (x) => x.ConversionRate, - newPlanBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newPlanPackage: (x) => x.ConversionRate, - newPlanMatrix: (x) => x.ConversionRate, - newPlanThresholdTotalAmount: (x) => x.ConversionRate, - newPlanTieredPackage: (x) => x.ConversionRate, - newPlanTieredWithMinimum: (x) => x.ConversionRate, - newPlanGroupedTiered: (x) => x.ConversionRate, - newPlanTieredPackageWithMinimum: (x) => x.ConversionRate, - newPlanPackageWithAllocation: (x) => x.ConversionRate, - newPlanUnitWithPercent: (x) => x.ConversionRate, - newPlanMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newPlanUnitWithProration: (x) => x.ConversionRate, - newPlanGroupedAllocation: (x) => x.ConversionRate, - newPlanBulkWithProration: (x) => x.ConversionRate, - newPlanGroupedWithProratedMinimum: (x) => x.ConversionRate, - newPlanGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newPlanMatrixWithDisplayName: (x) => x.ConversionRate, - newPlanGroupedTieredPackage: (x) => x.ConversionRate, - newPlanMaxGroupTieredPackage: (x) => x.ConversionRate, - newPlanScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newPlanScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newPlanCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newPlanMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + value = this.Value as 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; } - public string? Currency + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickMeteredAllowance(out var value)) { + /// // `value` is of type `ReplacePricePriceMeteredAllowance` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickMeteredAllowance( + [NotNullWhen(true)] out ReplacePricePriceMeteredAllowance? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.Currency, - newPlanTiered: (x) => x.Currency, - newPlanBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newPlanPackage: (x) => x.Currency, - newPlanMatrix: (x) => x.Currency, - newPlanThresholdTotalAmount: (x) => x.Currency, - newPlanTieredPackage: (x) => x.Currency, - newPlanTieredWithMinimum: (x) => x.Currency, - newPlanGroupedTiered: (x) => x.Currency, - newPlanTieredPackageWithMinimum: (x) => x.Currency, - newPlanPackageWithAllocation: (x) => x.Currency, - newPlanUnitWithPercent: (x) => x.Currency, - newPlanMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newPlanUnitWithProration: (x) => x.Currency, - newPlanGroupedAllocation: (x) => x.Currency, - newPlanBulkWithProration: (x) => x.Currency, - newPlanGroupedWithProratedMinimum: (x) => x.Currency, - newPlanGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newPlanMatrixWithDisplayName: (x) => x.Currency, - newPlanGroupedTieredPackage: (x) => x.Currency, - newPlanMaxGroupTieredPackage: (x) => x.Currency, - newPlanScalableMatrixWithUnitPricing: (x) => x.Currency, - newPlanScalableMatrixWithTieredPricing: (x) => x.Currency, - newPlanCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newPlanMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + value = this.Value as ReplacePricePriceMeteredAllowance; + return value != null; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPlanMinimumComposite(out var value)) { + /// // `value` is of type `NewPlanMinimumCompositePrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPlanMinimumComposite( + [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value + ) { - get - { - return Match( - newPlanUnit: (x) => x.DimensionalPriceConfiguration, - newPlanTiered: (x) => x.DimensionalPriceConfiguration, - newPlanBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newPlanPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMatrix: (x) => x.DimensionalPriceConfiguration, - newPlanThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newPlanTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newPlanBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newPlanMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newPlanGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithUnitPricing: (x) => x.DimensionalPriceConfiguration, - newPlanScalableMatrixWithTieredPricing: (x) => x.DimensionalPriceConfiguration, - newPlanCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newPlanMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + value = this.Value as NewPlanMinimumCompositePrice; + return value != null; } - public string? ExternalPriceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickPercent(out var value)) { + /// // `value` is of type `ReplacePricePricePercent` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) { - get - { - return Match( - newPlanUnit: (x) => x.ExternalPriceID, - newPlanTiered: (x) => x.ExternalPriceID, - newPlanBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newPlanPackage: (x) => x.ExternalPriceID, - newPlanMatrix: (x) => x.ExternalPriceID, - newPlanThresholdTotalAmount: (x) => x.ExternalPriceID, - newPlanTieredPackage: (x) => x.ExternalPriceID, - newPlanTieredWithMinimum: (x) => x.ExternalPriceID, - newPlanGroupedTiered: (x) => x.ExternalPriceID, - newPlanTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newPlanPackageWithAllocation: (x) => x.ExternalPriceID, - newPlanUnitWithPercent: (x) => x.ExternalPriceID, - newPlanMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newPlanUnitWithProration: (x) => x.ExternalPriceID, - newPlanGroupedAllocation: (x) => x.ExternalPriceID, - newPlanBulkWithProration: (x) => x.ExternalPriceID, - newPlanGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newPlanMatrixWithDisplayName: (x) => x.ExternalPriceID, - newPlanGroupedTieredPackage: (x) => x.ExternalPriceID, - newPlanMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newPlanCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newPlanMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + value = this.Value as ReplacePricePricePercent; + return value != null; } - public double? FixedPriceQuantity + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickEventOutput(out var value)) { + /// // `value` is of type `ReplacePricePriceEventOutput` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) { - get - { - return Match( - newPlanUnit: (x) => x.FixedPriceQuantity, - newPlanTiered: (x) => x.FixedPriceQuantity, - newPlanBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newPlanPackage: (x) => x.FixedPriceQuantity, - newPlanMatrix: (x) => x.FixedPriceQuantity, - newPlanThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newPlanTieredPackage: (x) => x.FixedPriceQuantity, - newPlanTieredWithMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedTiered: (x) => x.FixedPriceQuantity, - newPlanTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newPlanPackageWithAllocation: (x) => x.FixedPriceQuantity, - newPlanUnitWithPercent: (x) => x.FixedPriceQuantity, - newPlanMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newPlanUnitWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedAllocation: (x) => x.FixedPriceQuantity, - newPlanBulkWithProration: (x) => x.FixedPriceQuantity, - newPlanGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newPlanGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newPlanMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newPlanGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newPlanMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newPlanScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newPlanCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newPlanMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } + value = this.Value as ReplacePricePriceEventOutput; + return value != null; } - public string? InvoiceGroupingKey + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (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) => {...}, + /// (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 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) { - 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 - ); + 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 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" + ); } } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (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) => {...}, + /// (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 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 { - 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 - ); - } + 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 + ), + 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 string? ReferenceID - { - get - { - return Match( - newPlanUnit: (x) => x.ReferenceID, - newPlanTiered: (x) => x.ReferenceID, - newPlanBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newPlanPackage: (x) => x.ReferenceID, - newPlanMatrix: (x) => x.ReferenceID, - newPlanThresholdTotalAmount: (x) => x.ReferenceID, - newPlanTieredPackage: (x) => x.ReferenceID, - newPlanTieredWithMinimum: (x) => x.ReferenceID, - newPlanGroupedTiered: (x) => x.ReferenceID, - newPlanTieredPackageWithMinimum: (x) => x.ReferenceID, - newPlanPackageWithAllocation: (x) => x.ReferenceID, - newPlanUnitWithPercent: (x) => x.ReferenceID, - newPlanMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newPlanUnitWithProration: (x) => x.ReferenceID, - newPlanGroupedAllocation: (x) => x.ReferenceID, - newPlanBulkWithProration: (x) => x.ReferenceID, - newPlanGroupedWithProratedMinimum: (x) => x.ReferenceID, - newPlanGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newPlanMatrixWithDisplayName: (x) => x.ReferenceID, - newPlanGroupedTieredPackage: (x) => x.ReferenceID, - newPlanMaxGroupTieredPackage: (x) => x.ReferenceID, - newPlanScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newPlanScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newPlanCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newPlanMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } - } + public static implicit operator ReplacePricePrice(NewPlanUnitPrice value) => new(value); - public ReplacePricePrice(NewPlanUnitPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPrice value) => new(value); - public ReplacePricePrice(NewPlanTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanBulkPrice value) => new(value); - public ReplacePricePrice(NewPlanBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => + new(value); - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanPackagePrice value) => new(value); - public ReplacePricePrice(NewPlanPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMatrixPrice value) => new(value); - public ReplacePricePrice(NewPlanMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanThresholdTotalAmountPrice value) => + new(value); - public ReplacePricePrice(NewPlanThresholdTotalAmountPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPackagePrice value) => + new(value); - public ReplacePricePrice(NewPlanTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredWithMinimumPrice value) => + new(value); - public ReplacePricePrice(NewPlanTieredWithMinimumPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPrice value) => + new(value); - public ReplacePricePrice(NewPlanGroupedTieredPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanTieredPackageWithMinimumPrice value) => + new(value); - public ReplacePricePrice( - NewPlanTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanPackageWithAllocationPrice value) => + new(value); - public ReplacePricePrice(NewPlanPackageWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanUnitWithPercentPrice value) => + new(value); - public ReplacePricePrice(NewPlanUnitWithPercentPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMatrixWithAllocationPrice value) => + new(value); - public ReplacePricePrice(NewPlanMatrixWithAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => + new(value); - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanUnitWithProrationPrice value) => + new(value); - public ReplacePricePrice(NewPlanUnitWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanGroupedAllocationPrice value) => + new(value); - public ReplacePricePrice(NewPlanGroupedAllocationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanBulkWithProrationPrice value) => + new(value); - public ReplacePricePrice(NewPlanBulkWithProrationPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithProratedMinimumPrice value + ) => new(value); - public ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + NewPlanGroupedWithMeteredMinimumPrice value + ) => new(value); - public ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + ReplacePricePriceGroupedWithMinMaxThresholds value + ) => new(value); - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value) => + new(value); - public ReplacePricePrice(NewPlanMatrixWithDisplayNamePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanGroupedTieredPackagePrice value) => + new(value); - public ReplacePricePrice(NewPlanGroupedTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value) => + new(value); - public ReplacePricePrice(NewPlanMaxGroupTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithUnitPricingPrice value + ) => new(value); - public ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplacePricePrice( + NewPlanScalableMatrixWithTieredPricingPrice value + ) => new(value); - public ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + 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() { - this.Value = value; - this._element = element; + 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(), + (dailyCreditAllowance) => dailyCreditAllowance.Validate(), + (meteredAllowance) => meteredAllowance.Validate(), + (newPlanMinimumComposite) => newPlanMinimumComposite.Validate(), + (percent) => percent.Validate(), + (eventOutput) => eventOutput.Validate() + ); } - public ReplacePricePrice(NewPlanCumulativeGroupedBulkPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public virtual bool Equals(ReplacePricePrice? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + public override int GetHashCode() { - this.Value = value; - this._element = element; + return 0; } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - public ReplacePricePrice(NewPlanMinimumCompositePrice value, JsonElement? element = null) + int VariantIndex() { - this.Value = value; - this._element = element; + return this.Value switch + { + NewPlanUnitPrice _ => 0, + NewPlanTieredPrice _ => 1, + NewPlanBulkPrice _ => 2, + ReplacePricePriceBulkWithFilters _ => 3, + NewPlanPackagePrice _ => 4, + NewPlanMatrixPrice _ => 5, + NewPlanThresholdTotalAmountPrice _ => 6, + NewPlanTieredPackagePrice _ => 7, + NewPlanTieredWithMinimumPrice _ => 8, + NewPlanGroupedTieredPrice _ => 9, + NewPlanTieredPackageWithMinimumPrice _ => 10, + NewPlanPackageWithAllocationPrice _ => 11, + NewPlanUnitWithPercentPrice _ => 12, + NewPlanMatrixWithAllocationPrice _ => 13, + ReplacePricePriceTieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + ReplacePricePriceDailyCreditAllowance _ => 28, + ReplacePricePriceMeteredAllowance _ => 29, + NewPlanMinimumCompositePrice _ => 30, + ReplacePricePricePercent _ => 31, + ReplacePricePriceEventOutput _ => 32, + _ => -1, + }; } +} - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value, - JsonElement? element = null +sealed class ReplacePricePriceConverter : JsonConverter +{ + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; - } + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } - public ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice(JsonElement element) - { - this._element = element; - } + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 - ) - { - value = - this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters; - return value != null; - } + 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 + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanPackage(out var value)) { - /// // `value` is of type `NewPlanPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanPackage([NotNullWhen(true)] out NewPlanPackagePrice? value) - { - value = this.Value as NewPlanPackagePrice; - return value != null; - } + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanMatrix(out var value)) { - /// // `value` is of type `NewPlanMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanMatrix([NotNullWhen(true)] out NewPlanMatrixPrice? value) - { - value = this.Value as NewPlanMatrixPrice; - return value != null; - } + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewPlanThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanThresholdTotalAmount( - [NotNullWhen(true)] out NewPlanThresholdTotalAmountPrice? value - ) - { - value = this.Value as NewPlanThresholdTotalAmountPrice; - return value != null; - } + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackage(out var value)) { - /// // `value` is of type `NewPlanTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackage( - [NotNullWhen(true)] out NewPlanTieredPackagePrice? value - ) - { - value = this.Value as NewPlanTieredPackagePrice; - return value != null; - } + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredWithMinimum( - [NotNullWhen(true)] out NewPlanTieredWithMinimumPrice? value - ) - { - value = this.Value as NewPlanTieredWithMinimumPrice; - return value != null; - } + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanGroupedTiered(out var value)) { - /// // `value` is of type `NewPlanGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanGroupedTiered( - [NotNullWhen(true)] out NewPlanGroupedTieredPrice? value - ) - { - value = this.Value as NewPlanGroupedTieredPrice; - return value != null; - } + return new(element); + } + case "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 + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPlanTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewPlanTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewPlanTieredPackageWithMinimum( - [NotNullWhen(true)] out NewPlanTieredPackageWithMinimumPrice? value - ) - { - value = this.Value as NewPlanTieredPackageWithMinimumPrice; - return value != null; - } + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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; - } + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 - ) - { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration; - return value != null; - } + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "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 + } - /// - /// Returns true and sets the 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 "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 - ) - { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; - } + 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 + } - /// - /// Returns true and sets the 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 "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 + } - /// - /// Returns true and sets the 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 "daily_credit_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "metered_allowance": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "minimum_composite": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.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 "event_output": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation? value - ) - { - value = - this.Value - as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation; - return value != null; + return new(element); + } + default: + { + return new ReplacePricePrice(element); + } + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickMinimum(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum? value + public override void Write( + Utf8JsonWriter writer, + ReplacePricePrice? value, + JsonSerializerOptions options ) { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum; - return value != null; + JsonSerializer.Serialize(writer, value?.Json, options); } +} +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFilters, + ReplacePricePriceBulkWithFiltersFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFilters : 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.TryPickNewPlanMinimumComposite(out var value)) { - /// // `value` is of type `NewPlanMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// Configuration for bulk_with_filters pricing /// - public bool TryPickNewPlanMinimumComposite( - [NotNullWhen(true)] out NewPlanMinimumCompositePrice? value - ) + public required ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig BulkWithFiltersConfig { - value = this.Value as NewPlanMinimumCompositePrice; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "bulk_with_filters_config" + ); + } + init { this._rawData.Set("bulk_with_filters_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.TryPickPercent(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// + /// The cadence to bill for this price on. /// - public bool TryPickPercent( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent? value - ) + public required ApiEnum Cadence { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent; - 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the item the price will be associated with. /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput? value - ) + public required string ItemID { - value = this.Value as global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", 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 pricing model type /// - 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 JsonElement ModelType { - switch (this.Value) + get { - case NewPlanUnitPrice value: - newPlanUnit(value); - break; - case NewPlanTieredPrice value: - newPlanTiered(value); - break; - case NewPlanBulkPrice value: - newPlanBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewPlanPackagePrice value: - newPlanPackage(value); - break; - case NewPlanMatrixPrice value: - newPlanMatrix(value); - break; - case NewPlanThresholdTotalAmountPrice value: - newPlanThresholdTotalAmount(value); - break; - case NewPlanTieredPackagePrice value: - newPlanTieredPackage(value); - break; - case NewPlanTieredWithMinimumPrice value: - newPlanTieredWithMinimum(value); - break; - case NewPlanGroupedTieredPrice value: - newPlanGroupedTiered(value); - break; - case NewPlanTieredPackageWithMinimumPrice value: - newPlanTieredPackageWithMinimum(value); - break; - case NewPlanPackageWithAllocationPrice value: - newPlanPackageWithAllocation(value); - break; - case NewPlanUnitWithPercentPrice value: - newPlanUnitWithPercent(value); - break; - case NewPlanMatrixWithAllocationPrice value: - newPlanMatrixWithAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewPlanUnitWithProrationPrice value: - newPlanUnitWithProration(value); - break; - case NewPlanGroupedAllocationPrice value: - newPlanGroupedAllocation(value); - break; - case NewPlanBulkWithProrationPrice value: - newPlanBulkWithProration(value); - break; - case NewPlanGroupedWithProratedMinimumPrice value: - newPlanGroupedWithProratedMinimum(value); - break; - case NewPlanGroupedWithMeteredMinimumPrice value: - newPlanGroupedWithMeteredMinimum(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewPlanMatrixWithDisplayNamePrice value: - newPlanMatrixWithDisplayName(value); - break; - case NewPlanGroupedTieredPackagePrice value: - newPlanGroupedTieredPackage(value); - break; - case NewPlanMaxGroupTieredPackagePrice value: - newPlanMaxGroupTieredPackage(value); - break; - case NewPlanScalableMatrixWithUnitPricingPrice value: - newPlanScalableMatrixWithUnitPricing(value); - break; - case NewPlanScalableMatrixWithTieredPricingPrice value: - newPlanScalableMatrixWithTieredPricing(value); - break; - case NewPlanCumulativeGroupedBulkPrice value: - newPlanCumulativeGroupedBulk(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value: - minimum(value); - break; - case NewPlanMinimumCompositePrice value: - newPlanMinimumComposite(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value: - percent(value); - break; - case global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); } + init { this._rawData.Set("model_type", 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) => {...} - /// ); - /// - /// + /// The name of the price. /// - 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 required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + /// The id of the billable metric for the price. Only needed if the price is usage-based. + /// + public string? BillableMetricID { - 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("billable_metric_id"); + } + init { this._rawData.Set("billable_metric_id", value); } } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitPrice value - ) => new(value); - - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredPrice value - ) => new(value); + /// + /// If the Price represents a fixed cost, the price will be billed in-advance + /// if this is true, and in-arrears if this 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceBulkWithFilters 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanPackagePrice value - ) => new(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); } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - 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 global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanTieredWithMinimumPrice 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( - NewPlanGroupedTieredPrice 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( - NewPlanTieredPackageWithMinimumPrice 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( - NewPlanPackageWithAllocationPrice 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( - NewPlanUnitWithPercentPrice 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( - NewPlanMatrixWithAllocationPrice 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( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProration value - ) => new(value); + /// + public override void Validate() + { + this.BulkWithFiltersConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_filters") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanUnitWithProrationPrice value - ) => new(value); + public ReplacePricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedAllocationPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFilters( + ReplacePricePriceBulkWithFilters replacePricePriceBulkWithFilters + ) + : base(replacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanBulkWithProrationPrice value - ) => new(value); + public ReplacePricePriceBulkWithFilters(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithProratedMinimumPrice value - ) => new(value); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedWithMeteredMinimumPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFilters(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.ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); + /// + public static ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMatrixWithDisplayNamePrice value - ) => new(value); +class ReplacePricePriceBulkWithFiltersFromRaw : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFilters.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanGroupedTieredPackagePrice value - ) => new(value); +/// +/// Configuration for bulk_with_filters pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig : JsonModel +{ + /// + /// Property filters to apply (all must match) + /// + public required IReadOnlyList Filters + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("filters"); + } + init + { + this._rawData.Set< + ImmutableArray + >("filters", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMaxGroupTieredPackagePrice value - ) => new(value); + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithUnitPricingPrice value - ) => new(value); + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanScalableMatrixWithTieredPricingPrice value - ) => new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() { } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanCumulativeGroupedBulkPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig replacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfig) { } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceMinimum value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - NewPlanMinimumCompositePrice value - ) => new(value); + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercent value - ) => new(value); +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfig.FromRawUnchecked(rawData); +} - public static implicit operator global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice( - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutput value - ) => new(value); +/// +/// Configuration for a single property filter +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter : JsonModel +{ + /// + /// Event property key to filter on + /// + public required string PropertyKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } + } /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// + /// Event property value to match /// - public override void Validate() + public required string PropertyValue { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_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("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); } - public virtual bool Equals(global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? other) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + FrozenDictionary rawData + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + this._rawData = new(rawData); } +#pragma warning restore CS8618 - public override int GetHashCode() + /// + public static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - return 0; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); } -sealed class ReplacePricePriceConverter - : JsonConverter +/// +/// Configuration for a single bulk pricing tier +/// +[JsonConverter( + typeof(JsonModelConverter< + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier, + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + >) +)] +public sealed record class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier : JsonModel { - public override global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + /// Amount per unit + /// + public required string UnitAmount { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch + get { - modelType = null; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } + } - switch (modelType) + /// + /// The lower bound for this tier + /// + public string? TierLowerBound + { + 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 - } + this._rawData.Freeze(); + return this._rawData.GetNullableClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", value); } + } - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public override void Validate() + { + _ = this.UnitAmount; + _ = this.TierLowerBound; + } - 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base(replacePricePriceBulkWithFiltersBulkWithFiltersConfigTier) { } +#pragma warning restore CS8618 - 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 ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - 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] + ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#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 static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(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 - } + [SetsRequiredMembers] + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} - 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 - } +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked(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 - } +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersCadenceConverter))] +public enum ReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - return new(element); - } - case "tiered_with_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 - } +sealed class ReplacePricePriceBulkWithFiltersCadenceConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => ReplacePricePriceBulkWithFiltersCadence.Annual, + "semi_annual" => ReplacePricePriceBulkWithFiltersCadence.SemiAnnual, + "monthly" => ReplacePricePriceBulkWithFiltersCadence.Monthly, + "quarterly" => ReplacePricePriceBulkWithFiltersCadence.Quarterly, + "one_time" => ReplacePricePriceBulkWithFiltersCadence.OneTime, + "custom" => ReplacePricePriceBulkWithFiltersCadence.Custom, + _ => (ReplacePricePriceBulkWithFiltersCadence)(-1), + }; + } - return new(element); - } - case "unit_with_proration": + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence 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 - } + 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 + ); + } +} - 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(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : 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 + ); + } + } + + 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; + } - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } - 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + 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(ReplacePricePriceBulkWithFiltersConversionRateConfig? 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 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( + var deserialized = JsonSerializer.Deserialize( element, options ); if (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 +16908,39 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePrice? value, + ReplacePricePriceBulkWithFiltersConversionRateConfig 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 +16985,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 +17059,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 +17155,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17206,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 +17230,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 +17272,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 +17401,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -13815,79 +17409,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 +17500,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -13904,162 +17508,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 +17545,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14085,7 +17554,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14094,7 +17563,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -14103,7 +17572,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 +17593,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +17613,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +17624,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14176,7 +17645,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 +17654,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +17665,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14212,16 +17681,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 +17709,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 +17774,10 @@ JsonSerializerOptions 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 +17794,10 @@ JsonSerializerOptions 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 +17806,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 +17823,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 +17898,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 +17957,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 +18053,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18105,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 +18128,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 +18172,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 +18195,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 +18206,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 +18226,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 +18242,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 +18333,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -14986,8 +18341,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14995,22 +18350,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 +18380,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15036,7 +18389,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15045,7 +18398,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15054,7 +18407,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 +18428,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18448,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18459,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15127,7 +18480,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 +18489,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18500,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15163,16 +18516,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 +18544,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 +18563,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 +18611,10 @@ JsonSerializerOptions 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 +18631,10 @@ JsonSerializerOptions 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 +18643,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig( + return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -15290,7 +18652,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceTieredWithProrationConversionRateConfig value, + ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -15300,46 +18662,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 +18796,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 +18892,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18944,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 +18967,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 +19011,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 +19034,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 +19045,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 +19065,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 +19081,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 +19172,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -15872,8 +19180,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15881,22 +19189,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 +19219,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15922,7 +19228,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15931,7 +19237,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -15940,7 +19246,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 +19267,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -15981,7 +19287,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -15992,8 +19298,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16013,7 +19319,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 +19328,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -16033,8 +19339,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16049,16 +19355,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 +19383,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 +19402,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 +19450,10 @@ JsonSerializerOptions 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 +19470,10 @@ JsonSerializerOptions 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 +19482,7 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -16176,7 +19491,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16186,46 +19501,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 +19635,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 +19731,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19783,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 +19806,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 +19848,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 +19871,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 +19882,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 +19902,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 +19918,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 +20115,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 +20138,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -16758,8 +20146,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16767,22 +20155,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 +20185,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16808,7 +20194,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16817,7 +20203,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -16826,7 +20212,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 +20233,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +20253,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +20264,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16899,7 +20285,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 +20294,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +20305,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16935,16 +20321,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 +20349,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 +20366,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 +20414,10 @@ JsonSerializerOptions 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 +20434,10 @@ JsonSerializerOptions 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 +20446,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 +20463,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 +20498,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 +20597,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 +20693,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +20746,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 +20768,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 +20810,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 +20832,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 +20843,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 +20863,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 +20879,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 +20984,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 +21062,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17639,7 +21071,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17648,7 +21080,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -17657,7 +21089,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 +21110,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21130,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21141,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17730,7 +21162,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 +21171,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21182,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17766,16 +21198,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 +21226,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 +21243,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 +21291,10 @@ JsonSerializerOptions 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 +21311,10 @@ JsonSerializerOptions 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 +21323,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 +21339,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 +21400,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 +21471,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 +21567,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +21637,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18205,10 +21647,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 +21668,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 +21677,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 +21700,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 +21710,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 +21730,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 +21750,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 +21777,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 +21798,8 @@ public ReplacePricePricePercentPercentConfig(IReadOnlyDictionary - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePricePercentPercentConfig FromRawUnchecked( + /// + public static ReplacePricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18408,20 +21815,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 +21868,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 +21889,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21909,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21920,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18548,7 +21950,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21961,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18580,11 +21982,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 +22011,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 +22022,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 +22070,10 @@ JsonSerializerOptions 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 +22090,10 @@ JsonSerializerOptions 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 +22102,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 +22118,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 +22140,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 +22250,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 +22346,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22421,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19019,10 +22431,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 +22452,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 +22461,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 +22484,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 +22494,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 +22514,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 +22534,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 +22592,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 +22615,8 @@ IReadOnlyDictionary rawData } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static ReplacePricePriceEventOutputEventOutputConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -19274,20 +22632,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 +22685,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 +22706,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +22726,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +22737,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19414,7 +22767,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +22778,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19446,11 +22799,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 +22828,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 +22839,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 +22887,10 @@ JsonSerializerOptions 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 +22907,10 @@ JsonSerializerOptions 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 +22919,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig( - element - ); + return new ReplacePricePriceEventOutputConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.ExternalPlanID.ReplacePricePriceEventOutputConversionRateConfig value, + ReplacePricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs index be2e0796f..8a1c971e7 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDFetchPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint is used to fetch a plan version. It returns the phases, prices, /// and adjustments present on this version of the plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDFetchPlanVersionParams : ParamsBase +public record class ExternalPlanIDFetchPlanVersionParams : ParamsBase { public required string ExternalPlanID { get; init; } @@ -20,6 +24,8 @@ public sealed record class ExternalPlanIDFetchPlanVersionParams : ParamsBase public ExternalPlanIDFetchPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDFetchPlanVersionParams( ExternalPlanIDFetchPlanVersionParams externalPlanIDFetchPlanVersionParams ) @@ -28,6 +34,7 @@ ExternalPlanIDFetchPlanVersionParams externalPlanIDFetchPlanVersionParams this.ExternalPlanID = externalPlanIDFetchPlanVersionParams.ExternalPlanID; this.Version = externalPlanIDFetchPlanVersionParams.Version; } +#pragma warning restore CS8618 public ExternalPlanIDFetchPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -42,24 +49,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalPlanIDFetchPlanVersionParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalPlanID, + string version ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalPlanID = externalPlanID; + this.Version = version; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDFetchPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalPlanID, + string version ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalPlanID, + version + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["Version"] = JsonSerializer.SerializeToElement(this.Version), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ExternalPlanIDFetchPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return this.ExternalPlanID.Equals(other.ExternalPlanID) + && (this.Version?.Equals(other.Version) ?? other.Version == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -85,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs index 48f536f06..acde9dc09 100644 --- a/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs +++ b/src/Orb/Models/Beta/ExternalPlanID/ExternalPlanIDSetDefaultPlanVersionParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Beta.ExternalPlanID; /// /// This endpoint allows setting the default version of a plan. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalPlanIDSetDefaultPlanVersionParams : ParamsBase +public record class ExternalPlanIDSetDefaultPlanVersionParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -37,6 +41,8 @@ public required long Version public ExternalPlanIDSetDefaultPlanVersionParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalPlanIDSetDefaultPlanVersionParams( ExternalPlanIDSetDefaultPlanVersionParams externalPlanIDSetDefaultPlanVersionParams ) @@ -46,6 +52,7 @@ ExternalPlanIDSetDefaultPlanVersionParams externalPlanIDSetDefaultPlanVersionPar this._rawBodyData = new(externalPlanIDSetDefaultPlanVersionParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalPlanIDSetDefaultPlanVersionParams( IReadOnlyDictionary rawHeaderData, @@ -63,27 +70,61 @@ IReadOnlyDictionary rawBodyData ExternalPlanIDSetDefaultPlanVersionParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalPlanID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalPlanID = externalPlanID; } #pragma warning restore CS8618 - /// + /// public static ExternalPlanIDSetDefaultPlanVersionParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalPlanID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalPlanID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalPlanID"] = JsonSerializer.SerializeToElement(this.ExternalPlanID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ExternalPlanIDSetDefaultPlanVersionParams? other) + { + if (other == null) + { + return false; + } + return (this.ExternalPlanID?.Equals(other.ExternalPlanID) ?? other.ExternalPlanID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -117,4 +158,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Beta/PlanVersion.cs b/src/Orb/Models/Beta/PlanVersion.cs index 2e2dc1603..441a2571f 100644 --- a/src/Orb/Models/Beta/PlanVersion.cs +++ b/src/Orb/Models/Beta/PlanVersion.cs @@ -117,8 +117,11 @@ public override void Validate() public PlanVersion() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanVersion(PlanVersion planVersion) : base(planVersion) { } +#pragma warning restore CS8618 public PlanVersion(IReadOnlyDictionary rawData) { @@ -289,7 +292,7 @@ public PlanVersionAdjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -312,7 +315,7 @@ public bool TryPickPlanPhaseUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -335,7 +338,7 @@ public bool TryPickPlanPhaseAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -358,7 +361,7 @@ public bool TryPickPlanPhasePercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -381,7 +384,7 @@ public bool TryPickPlanPhaseMinimum( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -403,7 +406,7 @@ public bool TryPickPlanPhaseMaximum( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -414,11 +417,11 @@ public bool TryPickPlanPhaseMaximum( /// /// /// instance.Switch( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -459,7 +462,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -470,11 +473,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, - /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, - /// (Models::PlanPhaseMinimumAdjustment value) => {...}, - /// (Models::PlanPhaseMaximumAdjustment value) => {...} + /// (Models::PlanPhaseUsageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseAmountDiscountAdjustment value) => {...}, + /// (Models::PlanPhasePercentageDiscountAdjustment value) => {...}, + /// (Models::PlanPhaseMinimumAdjustment value) => {...}, + /// (Models::PlanPhaseMaximumAdjustment value) => {...} /// ); /// /// @@ -549,10 +552,10 @@ public override void Validate() ); } - public virtual bool Equals(PlanVersionAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PlanVersionAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -560,7 +563,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Models::PlanPhaseUsageDiscountAdjustment _ => 0, + Models::PlanPhaseAmountDiscountAdjustment _ => 1, + Models::PlanPhasePercentageDiscountAdjustment _ => 2, + Models::PlanPhaseMinimumAdjustment _ => 3, + Models::PlanPhaseMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class PlanVersionAdjustmentConverter : JsonConverter @@ -595,12 +614,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -618,12 +635,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -641,12 +656,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -664,12 +677,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Beta/PlanVersionPhase.cs b/src/Orb/Models/Beta/PlanVersionPhase.cs index c31e3cce9..1952ebc5d 100644 --- a/src/Orb/Models/Beta/PlanVersionPhase.cs +++ b/src/Orb/Models/Beta/PlanVersionPhase.cs @@ -46,14 +46,12 @@ public required long? Duration init { this._rawData.Set("duration", value); } } - public required ApiEnum? DurationUnit + public required ApiEnum? DurationUnit { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("duration_unit"); + return this._rawData.GetNullableClass>("duration_unit"); } init { this._rawData.Set("duration_unit", value); } } @@ -94,8 +92,11 @@ public override void Validate() public PlanVersionPhase() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PlanVersionPhase(PlanVersionPhase planVersionPhase) : base(planVersionPhase) { } +#pragma warning restore CS8618 public PlanVersionPhase(IReadOnlyDictionary rawData) { @@ -126,7 +127,7 @@ public PlanVersionPhase FromRawUnchecked(IReadOnlyDictionary +sealed class DurationUnitConverter : JsonConverter { - public override global::Orb.Models.Beta.DurationUnit Read( + public override DurationUnit Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -146,18 +147,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "daily" => global::Orb.Models.Beta.DurationUnit.Daily, - "monthly" => global::Orb.Models.Beta.DurationUnit.Monthly, - "quarterly" => global::Orb.Models.Beta.DurationUnit.Quarterly, - "semi_annual" => global::Orb.Models.Beta.DurationUnit.SemiAnnual, - "annual" => global::Orb.Models.Beta.DurationUnit.Annual, - _ => (global::Orb.Models.Beta.DurationUnit)(-1), + "daily" => DurationUnit.Daily, + "monthly" => DurationUnit.Monthly, + "quarterly" => DurationUnit.Quarterly, + "semi_annual" => DurationUnit.SemiAnnual, + "annual" => DurationUnit.Annual, + _ => (DurationUnit)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Beta.DurationUnit value, + DurationUnit value, JsonSerializerOptions options ) { @@ -165,11 +166,11 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Beta.DurationUnit.Daily => "daily", - global::Orb.Models.Beta.DurationUnit.Monthly => "monthly", - global::Orb.Models.Beta.DurationUnit.Quarterly => "quarterly", - global::Orb.Models.Beta.DurationUnit.SemiAnnual => "semi_annual", - global::Orb.Models.Beta.DurationUnit.Annual => "annual", + DurationUnit.Daily => "daily", + DurationUnit.Monthly => "monthly", + DurationUnit.Quarterly => "quarterly", + DurationUnit.SemiAnnual => "semi_annual", + DurationUnit.Annual => "annual", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/BillableMetricTiny.cs b/src/Orb/Models/BillableMetricTiny.cs index 01798a6bc..278ff150c 100644 --- a/src/Orb/Models/BillableMetricTiny.cs +++ b/src/Orb/Models/BillableMetricTiny.cs @@ -28,8 +28,11 @@ public override void Validate() public BillableMetricTiny() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetricTiny(BillableMetricTiny billableMetricTiny) : base(billableMetricTiny) { } +#pragma warning restore CS8618 public BillableMetricTiny(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BillingCycleAnchorConfiguration.cs b/src/Orb/Models/BillingCycleAnchorConfiguration.cs index 14e19a556..fe6ba0edc 100644 --- a/src/Orb/Models/BillingCycleAnchorConfiguration.cs +++ b/src/Orb/Models/BillingCycleAnchorConfiguration.cs @@ -69,10 +69,13 @@ public override void Validate() public BillingCycleAnchorConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillingCycleAnchorConfiguration( BillingCycleAnchorConfiguration billingCycleAnchorConfiguration ) : base(billingCycleAnchorConfiguration) { } +#pragma warning restore CS8618 public BillingCycleAnchorConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BillingCycleConfiguration.cs b/src/Orb/Models/BillingCycleConfiguration.cs index 8cc67f072..53ba01b0e 100644 --- a/src/Orb/Models/BillingCycleConfiguration.cs +++ b/src/Orb/Models/BillingCycleConfiguration.cs @@ -43,8 +43,11 @@ public override void Validate() public BillingCycleConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillingCycleConfiguration(BillingCycleConfiguration billingCycleConfiguration) : base(billingCycleConfiguration) { } +#pragma warning restore CS8618 public BillingCycleConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BulkConfig.cs b/src/Orb/Models/BulkConfig.cs index 81f648b0e..0650bf979 100644 --- a/src/Orb/Models/BulkConfig.cs +++ b/src/Orb/Models/BulkConfig.cs @@ -44,8 +44,11 @@ public override void Validate() public BulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkConfig(BulkConfig bulkConfig) : base(bulkConfig) { } +#pragma warning restore CS8618 public BulkConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/BulkTier.cs b/src/Orb/Models/BulkTier.cs index 9e46c5456..42a32b12a 100644 --- a/src/Orb/Models/BulkTier.cs +++ b/src/Orb/Models/BulkTier.cs @@ -48,8 +48,11 @@ public override void Validate() public BulkTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkTier(BulkTier bulkTier) : base(bulkTier) { } +#pragma warning restore CS8618 public BulkTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ChangedSubscriptionResources.cs b/src/Orb/Models/ChangedSubscriptionResources.cs index 838014e07..c146e913f 100644 --- a/src/Orb/Models/ChangedSubscriptionResources.cs +++ b/src/Orb/Models/ChangedSubscriptionResources.cs @@ -120,8 +120,11 @@ public override void Validate() public ChangedSubscriptionResources() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ChangedSubscriptionResources(ChangedSubscriptionResources changedSubscriptionResources) : base(changedSubscriptionResources) { } +#pragma warning restore CS8618 public ChangedSubscriptionResources(IReadOnlyDictionary rawData) { @@ -352,31 +355,32 @@ public required IReadOnlyList CustomerBalanceTransac /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public required CustomerTaxID? CustomerTaxID { @@ -893,9 +897,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice(CreatedInvoice createdInvoice) : base(createdInvoice) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public CreatedInvoice(IReadOnlyDictionary rawData) @@ -1001,8 +1008,11 @@ public override void Validate() public AutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } +#pragma warning restore CS8618 public AutoCollection(IReadOnlyDictionary rawData) { @@ -1125,8 +1135,11 @@ public override void Validate() public CreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditNote(CreditNote creditNote) : base(creditNote) { } +#pragma warning restore CS8618 public CreditNote(IReadOnlyDictionary rawData) { @@ -1296,8 +1309,11 @@ public override void Validate() public CustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } +#pragma warning restore CS8618 public CustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1516,8 +1532,8 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// public required IReadOnlyList Adjustments { @@ -1783,8 +1799,11 @@ public override void Validate() public LineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { @@ -1943,7 +1962,7 @@ public LineItemAdjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1966,7 +1985,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1989,7 +2008,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2012,7 +2031,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2033,7 +2052,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2053,7 +2072,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2064,11 +2083,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2109,7 +2128,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2120,11 +2139,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2193,10 +2212,10 @@ public override void Validate() ); } - public virtual bool Equals(LineItemAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LineItemAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2204,7 +2223,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class LineItemAdjustmentConverter : JsonConverter @@ -2238,12 +2273,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2260,12 +2293,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2283,12 +2314,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2305,12 +2334,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2327,12 +2354,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2438,7 +2463,7 @@ public SubLineItem(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2459,7 +2484,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2480,7 +2505,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2500,7 +2525,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2511,9 +2536,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2544,7 +2569,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2555,9 +2580,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2606,10 +2631,10 @@ public override void Validate() ); } - public virtual bool Equals(SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2617,7 +2642,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class SubLineItemConverter : JsonConverter @@ -2651,12 +2690,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2673,12 +2710,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2695,12 +2730,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2835,8 +2868,11 @@ public override void Validate() public PaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } +#pragma warning restore CS8618 public PaymentAttempt(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateTier.cs b/src/Orb/Models/ConversionRateTier.cs index 112380ab3..9ddfb5687 100644 --- a/src/Orb/Models/ConversionRateTier.cs +++ b/src/Orb/Models/ConversionRateTier.cs @@ -59,8 +59,11 @@ public override void Validate() public ConversionRateTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateTier(ConversionRateTier conversionRateTier) : base(conversionRateTier) { } +#pragma warning restore CS8618 public ConversionRateTier(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateTieredConfig.cs b/src/Orb/Models/ConversionRateTieredConfig.cs index c3e5a33d0..78bb374bd 100644 --- a/src/Orb/Models/ConversionRateTieredConfig.cs +++ b/src/Orb/Models/ConversionRateTieredConfig.cs @@ -43,8 +43,11 @@ public override void Validate() public ConversionRateTieredConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateTieredConfig(ConversionRateTieredConfig conversionRateTieredConfig) : base(conversionRateTieredConfig) { } +#pragma warning restore CS8618 public ConversionRateTieredConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/ConversionRateUnitConfig.cs b/src/Orb/Models/ConversionRateUnitConfig.cs index dd6ce120f..9eac0a9ba 100644 --- a/src/Orb/Models/ConversionRateUnitConfig.cs +++ b/src/Orb/Models/ConversionRateUnitConfig.cs @@ -33,8 +33,11 @@ public override void Validate() public ConversionRateUnitConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ConversionRateUnitConfig(ConversionRateUnitConfig conversionRateUnitConfig) : base(conversionRateUnitConfig) { } +#pragma warning restore CS8618 public ConversionRateUnitConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/CouponRedemption.cs b/src/Orb/Models/CouponRedemption.cs index 73e7fe803..55c00b81e 100644 --- a/src/Orb/Models/CouponRedemption.cs +++ b/src/Orb/Models/CouponRedemption.cs @@ -51,8 +51,11 @@ public override void Validate() public CouponRedemption() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponRedemption(CouponRedemption couponRedemption) : base(couponRedemption) { } +#pragma warning restore CS8618 public CouponRedemption(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/Coupon.cs b/src/Orb/Models/Coupons/Coupon.cs index 2783b1732..8f6921e29 100644 --- a/src/Orb/Models/Coupons/Coupon.cs +++ b/src/Orb/Models/Coupons/Coupon.cs @@ -123,8 +123,11 @@ public override void Validate() public Coupon() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Coupon(Coupon coupon) : base(coupon) { } +#pragma warning restore CS8618 public Coupon(IReadOnlyDictionary rawData) { @@ -197,7 +200,7 @@ public CouponDiscount(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -218,7 +221,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscount? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -238,7 +241,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -249,8 +252,8 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// /// /// instance.Switch( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -279,7 +282,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -290,8 +293,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...} /// ); /// /// @@ -334,10 +337,10 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(CouponDiscount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CouponDiscount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -345,7 +348,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + AmountDiscount _ => 1, + _ => -1, + }; + } } sealed class CouponDiscountConverter : JsonConverter @@ -379,12 +395,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -398,12 +412,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Coupons/CouponArchiveParams.cs b/src/Orb/Models/Coupons/CouponArchiveParams.cs index c952ddf51..738faa32c 100644 --- a/src/Orb/Models/Coupons/CouponArchiveParams.cs +++ b/src/Orb/Models/Coupons/CouponArchiveParams.cs @@ -12,18 +12,25 @@ namespace Orb.Models.Coupons; /// This endpoint allows a coupon to be archived. Archived coupons can no longer be /// redeemed, and will be hidden from lists of active coupons. Additionally, once /// a coupon is archived, its redemption code can be reused for a different coupon. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponArchiveParams : ParamsBase +public record class CouponArchiveParams : ParamsBase { public string? CouponID { get; init; } public CouponArchiveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponArchiveParams(CouponArchiveParams couponArchiveParams) : base(couponArchiveParams) { this.CouponID = couponArchiveParams.CouponID; } +#pragma warning restore CS8618 public CouponArchiveParams( IReadOnlyDictionary rawHeaderData, @@ -38,24 +45,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CouponArchiveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static CouponArchiveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CouponArchiveParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -77,4 +116,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/CouponCreateParams.cs b/src/Orb/Models/Coupons/CouponCreateParams.cs index 036e75ba0..4a57db6da 100644 --- a/src/Orb/Models/Coupons/CouponCreateParams.cs +++ b/src/Orb/Models/Coupons/CouponCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Coupons; /// /// This endpoint allows the creation of coupons, which can then be redeemed at subscription /// creation or plan change. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponCreateParams : ParamsBase +public record class CouponCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -23,14 +27,12 @@ public IReadOnlyDictionary RawBodyData get { return this._rawBodyData.Freeze(); } } - public required global::Orb.Models.Coupons.Discount Discount + public required Discount Discount { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass( - "discount" - ); + return this._rawBodyData.GetNotNullClass("discount"); } init { this._rawBodyData.Set("discount", value); } } @@ -78,11 +80,14 @@ public long? MaxRedemptions public CouponCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponCreateParams(CouponCreateParams couponCreateParams) : base(couponCreateParams) { this._rawBodyData = new(couponCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CouponCreateParams( IReadOnlyDictionary rawHeaderData, @@ -109,7 +114,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CouponCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -123,6 +128,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/coupons") @@ -148,6 +181,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(DiscountConverter))] @@ -194,7 +232,7 @@ public Discount(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -215,7 +253,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out Percentage? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -235,7 +273,7 @@ public bool TryPickAmount([NotNullWhen(true)] out Amount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -246,8 +284,8 @@ public bool TryPickAmount([NotNullWhen(true)] out Amount? value) /// /// /// instance.Switch( - /// (Percentage value) => {...}, - /// (Amount value) => {...} + /// (Percentage value) => {...}, + /// (Amount value) => {...} /// ); /// /// @@ -271,7 +309,7 @@ public void Switch(System::Action percentage, System::Action /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -282,8 +320,8 @@ public void Switch(System::Action percentage, System::Action /// /// /// var result = instance.Match( - /// (Percentage value) => {...}, - /// (Amount value) => {...} + /// (Percentage value) => {...}, + /// (Amount value) => {...} /// ); /// /// @@ -298,10 +336,9 @@ public T Match(System::Func percentage, System::Func - new(value); + public static implicit operator Discount(Percentage value) => new(value); - public static implicit operator global::Orb.Models.Coupons.Discount(Amount value) => new(value); + public static implicit operator Discount(Amount value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -322,10 +359,10 @@ public override void Validate() this.Switch((percentage) => percentage.Validate(), (amount) => amount.Validate()); } - public virtual bool Equals(global::Orb.Models.Coupons.Discount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Discount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -333,12 +370,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Percentage _ => 0, + Amount _ => 1, + _ => -1, + }; + } } -sealed class DiscountConverter : JsonConverter +sealed class DiscountConverter : JsonConverter { - public override global::Orb.Models.Coupons.Discount? Read( + public override Discount? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -364,12 +414,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -383,12 +431,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -397,16 +443,12 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Coupons.Discount(element); + return new Discount(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Coupons.Discount value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Discount value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -455,8 +497,11 @@ public Percentage() this.DiscountType = JsonSerializer.SerializeToElement("percentage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percentage(Percentage percentage) : base(percentage) { } +#pragma warning restore CS8618 public Percentage(IReadOnlyDictionary rawData) { @@ -532,8 +577,11 @@ public Amount() this.DiscountType = JsonSerializer.SerializeToElement("amount"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amount(Amount amount) : base(amount) { } +#pragma warning restore CS8618 public Amount(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/CouponFetchParams.cs b/src/Orb/Models/Coupons/CouponFetchParams.cs index bd33502d5..16776c13c 100644 --- a/src/Orb/Models/Coupons/CouponFetchParams.cs +++ b/src/Orb/Models/Coupons/CouponFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Coupons; /// /// This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption /// code, use the [List coupons](list-coupons) endpoint with the redemption_code parameter. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponFetchParams : ParamsBase +public record class CouponFetchParams : ParamsBase { public string? CouponID { get; init; } public CouponFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponFetchParams(CouponFetchParams couponFetchParams) : base(couponFetchParams) { this.CouponID = couponFetchParams.CouponID; } +#pragma warning restore CS8618 public CouponFetchParams( IReadOnlyDictionary rawHeaderData, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CouponFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static CouponFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CouponFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/CouponListPage.cs b/src/Orb/Models/Coupons/CouponListPage.cs index 3febee959..ef0181222 100644 --- a/src/Orb/Models/Coupons/CouponListPage.cs +++ b/src/Orb/Models/Coupons/CouponListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -62,5 +63,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not CouponListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Coupons/CouponListPageResponse.cs b/src/Orb/Models/Coupons/CouponListPageResponse.cs index e6949cce7..a6540f7e2 100644 --- a/src/Orb/Models/Coupons/CouponListPageResponse.cs +++ b/src/Orb/Models/Coupons/CouponListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public CouponListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponListPageResponse(CouponListPageResponse couponListPageResponse) : base(couponListPageResponse) { } +#pragma warning restore CS8618 public CouponListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Coupons/CouponListParams.cs b/src/Orb/Models/Coupons/CouponListParams.cs index 08ed5b233..99edc267c 100644 --- a/src/Orb/Models/Coupons/CouponListParams.cs +++ b/src/Orb/Models/Coupons/CouponListParams.cs @@ -13,10 +13,13 @@ namespace Orb.Models.Coupons; /// /// The list of coupons is ordered starting from the most recently created /// coupon. The response also includes `pagination_metadata`, which lets the caller -/// retrieve the next page of results if they exist. More information about pagination -/// can be found in the Pagination-metadata schema. +/// retrieve the next page of results if they exist. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CouponListParams : ParamsBase +public record class CouponListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -81,8 +84,11 @@ public bool? ShowArchived public CouponListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CouponListParams(CouponListParams couponListParams) : base(couponListParams) { } +#pragma warning restore CS8618 public CouponListParams( IReadOnlyDictionary rawHeaderData, @@ -105,7 +111,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CouponListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -117,6 +123,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CouponListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/coupons") @@ -133,4 +165,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs index 7220cf504..f3ef2dae1 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -64,5 +65,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not SubscriptionListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs index aa9f3573d..ca6442f00 100644 --- a/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs +++ b/src/Orb/Models/Coupons/Subscriptions/SubscriptionListParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Coupons.Subscriptions; /// as a [paginated](/api-reference/pagination) list, ordered starting from the most /// recently created subscription. For a full discussion of the subscription resource, /// see [Subscription](/core-concepts#subscription). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionListParams : ParamsBase +public record class SubscriptionListParams : ParamsBase { public string? CouponID { get; init; } @@ -55,11 +59,14 @@ public long? Limit public SubscriptionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionListParams(SubscriptionListParams subscriptionListParams) : base(subscriptionListParams) { this.CouponID = subscriptionListParams.CouponID; } +#pragma warning restore CS8618 public SubscriptionListParams( IReadOnlyDictionary rawHeaderData, @@ -74,24 +81,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] SubscriptionListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string couponID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CouponID = couponID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string couponID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + couponID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CouponID"] = JsonSerializer.SerializeToElement(this.CouponID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(SubscriptionListParams? other) + { + if (other == null) + { + return false; + } + return (this.CouponID?.Equals(other.CouponID) ?? other.CouponID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -113,4 +152,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs index 1969fb284..a6e15eb34 100644 --- a/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs +++ b/src/Orb/Models/CreditBlocks/CreditBlockDeleteParams.cs @@ -17,21 +17,28 @@ namespace Orb.Models.CreditBlocks; /// purchase of the credit block, they will be deleted if in draft status, voided /// if issued, or a credit note will be issued if the invoice is paid. /// -/// Issued invoices that had credits applied from this block will not -/// be regenerated, but the ledger will reflect the state as if credits from the -/// deleted block were never applied. +/// <Note> Issued invoices that had credits applied from this block will +/// not be regenerated, but the ledger will reflect the state as if credits from the +/// deleted block were never applied. </Note> +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditBlockDeleteParams : ParamsBase +public record class CreditBlockDeleteParams : ParamsBase { public string? BlockID { get; init; } public CreditBlockDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockDeleteParams(CreditBlockDeleteParams creditBlockDeleteParams) : base(creditBlockDeleteParams) { this.BlockID = creditBlockDeleteParams.BlockID; } +#pragma warning restore CS8618 public CreditBlockDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditBlockDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string blockID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BlockID = blockID; } #pragma warning restore CS8618 - /// + /// public static CreditBlockDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string blockID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + blockID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BlockID"] = JsonSerializer.SerializeToElement(this.BlockID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditBlockDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.BlockID?.Equals(other.BlockID) ?? other.BlockID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs b/src/Orb/Models/CreditBlocks/CreditBlockListInvoicesParams.cs new file mode 100644 index 000000000..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..86f7e3812 100644 --- a/src/Orb/Models/CustomerTaxID.cs +++ b/src/Orb/Models/CustomerTaxID.cs @@ -84,30 +84,30 @@ namespace Orb.Models; /// Number | | Norway | `no_voec` | Norwegian VAT on e-commerce Number | | Oman | /// `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian RUC Number | | Philippines /// | `ph_tin` | Philippines Tax Identification Number | | Poland | `eu_vat` | European -/// VAT Number | | Portugal | `eu_vat` | European VAT Number | | Romania | `eu_vat` -/// | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number | | Russia -/// | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | | Saudi Arabia -/// | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal NINEA Number -/// | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` | Singaporean -/// GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia | `eu_vat` | European -/// VAT Number | | Slovenia | `eu_vat` | European VAT Number | | Slovenia | `si_tin` -/// | Slovenia Tax Number (davčna številka) | | South Africa | `za_vat` | South African -/// VAT Number | | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish -/// NIF Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT -/// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` | European -/// VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number | | Switzerland -/// | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | -/// Tajikistan | `tj_tin` | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` -/// | Tanzania VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` -/// | Turkish Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification -/// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` -/// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom VAT -/// Number | | United States | `us_ein` | United States EIN | | Uruguay | `uy_ruc` -/// | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN Number | | -/// Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` | Venezuelan -/// RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` -/// | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification -/// Number | +/// VAT Number | | Poland | `pl_nip` | Polish Tax ID Number | | Portugal | `eu_vat` +/// | European VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania +/// | `ro_tin` | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia +/// | `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal +/// | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number +/// | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` | Singaporean +/// UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European +/// VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | +/// South Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` +/// | Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF +/// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` | +/// Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland +/// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland +/// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` | +/// Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania VAT Number +/// | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification +/// Number | | Uganda | `ug_tin` | Uganda Tax Identification Number | | Ukraine | +/// `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates +/// TRN | | United Kingdom | `gb_vat` | United Kingdom VAT Number | | United States +/// | `us_ein` | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | +/// | Uzbekistan | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan +/// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | `vn_tin` +/// | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification Number +/// | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | /// [JsonConverter(typeof(JsonModelConverter))] public sealed record class CustomerTaxID : JsonModel @@ -152,8 +152,11 @@ public override void Validate() public CustomerTaxID() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerTaxID(CustomerTaxID customerTaxID) : base(customerTaxID) { } +#pragma warning restore CS8618 public CustomerTaxID(IReadOnlyDictionary rawData) { @@ -638,6 +641,7 @@ public enum CustomerTaxIDType OmVat, PeRuc, PhTin, + PlNip, RoTin, RsPib, RuInn, @@ -760,6 +764,7 @@ JsonSerializerOptions options "om_vat" => CustomerTaxIDType.OmVat, "pe_ruc" => CustomerTaxIDType.PeRuc, "ph_tin" => CustomerTaxIDType.PhTin, + "pl_nip" => CustomerTaxIDType.PlNip, "ro_tin" => CustomerTaxIDType.RoTin, "rs_pib" => CustomerTaxIDType.RsPib, "ru_inn" => CustomerTaxIDType.RuInn, @@ -884,6 +889,7 @@ JsonSerializerOptions options CustomerTaxIDType.OmVat => "om_vat", CustomerTaxIDType.PeRuc => "pe_ruc", CustomerTaxIDType.PhTin => "ph_tin", + CustomerTaxIDType.PlNip => "pl_nip", CustomerTaxIDType.RoTin => "ro_tin", CustomerTaxIDType.RsPib => "rs_pib", CustomerTaxIDType.RuInn => "ru_inn", diff --git a/src/Orb/Models/Customers/AccountingProviderConfig.cs b/src/Orb/Models/Customers/AccountingProviderConfig.cs index a10b1a4d5..7e3b9482c 100644 --- a/src/Orb/Models/Customers/AccountingProviderConfig.cs +++ b/src/Orb/Models/Customers/AccountingProviderConfig.cs @@ -41,8 +41,11 @@ public override void Validate() public AccountingProviderConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProviderConfig(AccountingProviderConfig accountingProviderConfig) : base(accountingProviderConfig) { } +#pragma warning restore CS8618 public AccountingProviderConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/AddressInput.cs b/src/Orb/Models/Customers/AddressInput.cs index 5fa5faa37..d7a10513c 100644 --- a/src/Orb/Models/Customers/AddressInput.cs +++ b/src/Orb/Models/Customers/AddressInput.cs @@ -83,8 +83,11 @@ public override void Validate() public AddressInput() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddressInput(AddressInput addressInput) : base(addressInput) { } +#pragma warning restore CS8618 public AddressInput(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs index ac1d4a588..f120bb830 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Customers.BalanceTransactions; /// /// Creates an immutable balance transaction that updates the customer's balance /// and returns back the newly created transaction. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BalanceTransactionCreateParams : ParamsBase +public record class BalanceTransactionCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -62,6 +66,8 @@ public string? Description public BalanceTransactionCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionCreateParams( BalanceTransactionCreateParams balanceTransactionCreateParams ) @@ -71,6 +77,7 @@ BalanceTransactionCreateParams balanceTransactionCreateParams this._rawBodyData = new(balanceTransactionCreateParams._rawBodyData); } +#pragma warning restore CS8618 public BalanceTransactionCreateParams( IReadOnlyDictionary rawHeaderData, @@ -88,29 +95,63 @@ IReadOnlyDictionary rawBodyData BalanceTransactionCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static BalanceTransactionCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BalanceTransactionCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -139,9 +180,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs index 226a4f498..cc56b8690 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionCreateResponse.cs @@ -30,14 +30,12 @@ public required string ID init { this._rawData.Set("id", value); } } - public required ApiEnum Action + public required ApiEnum Action { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("action"); + return this._rawData.GetNotNullClass>("action"); } init { this._rawData.Set("action", value); } } @@ -157,10 +155,13 @@ public override void Validate() public BalanceTransactionCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionCreateResponse( BalanceTransactionCreateResponse balanceTransactionCreateResponse ) : base(balanceTransactionCreateResponse) { } +#pragma warning restore CS8618 public BalanceTransactionCreateResponse(IReadOnlyDictionary rawData) { @@ -192,7 +193,7 @@ IReadOnlyDictionary rawData ) => BalanceTransactionCreateResponse.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Customers.BalanceTransactions.ActionConverter))] +[JsonConverter(typeof(ActionConverter))] public enum Action { AppliedToInvoice, @@ -207,10 +208,9 @@ public enum Action SmallInvoiceCarryover, } -sealed class ActionConverter - : JsonConverter +sealed class ActionConverter : JsonConverter { - public override global::Orb.Models.Customers.BalanceTransactions.Action Read( + public override Action Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -218,100 +218,36 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "applied_to_invoice" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .AppliedToInvoice, - "manual_adjustment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ManualAdjustment, - "prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ProratedRefund, - "revert_prorated_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .RevertProratedRefund, - "return_from_voiding" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ReturnFromVoiding, - "credit_note_applied" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteApplied, - "credit_note_voided" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .CreditNoteVoided, - "overpayment_refund" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .OverpaymentRefund, - "external_payment" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .ExternalPayment, - "small_invoice_carryover" => global::Orb - .Models - .Customers - .BalanceTransactions - .Action - .SmallInvoiceCarryover, - _ => (global::Orb.Models.Customers.BalanceTransactions.Action)(-1), + "applied_to_invoice" => Action.AppliedToInvoice, + "manual_adjustment" => Action.ManualAdjustment, + "prorated_refund" => Action.ProratedRefund, + "revert_prorated_refund" => Action.RevertProratedRefund, + "return_from_voiding" => Action.ReturnFromVoiding, + "credit_note_applied" => Action.CreditNoteApplied, + "credit_note_voided" => Action.CreditNoteVoided, + "overpayment_refund" => Action.OverpaymentRefund, + "external_payment" => Action.ExternalPayment, + "small_invoice_carryover" => Action.SmallInvoiceCarryover, + _ => (Action)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.BalanceTransactions.Action value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Action value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.BalanceTransactions.Action.AppliedToInvoice => - "applied_to_invoice", - global::Orb.Models.Customers.BalanceTransactions.Action.ManualAdjustment => - "manual_adjustment", - global::Orb.Models.Customers.BalanceTransactions.Action.ProratedRefund => - "prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.RevertProratedRefund => - "revert_prorated_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ReturnFromVoiding => - "return_from_voiding", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteApplied => - "credit_note_applied", - global::Orb.Models.Customers.BalanceTransactions.Action.CreditNoteVoided => - "credit_note_voided", - global::Orb.Models.Customers.BalanceTransactions.Action.OverpaymentRefund => - "overpayment_refund", - global::Orb.Models.Customers.BalanceTransactions.Action.ExternalPayment => - "external_payment", - global::Orb.Models.Customers.BalanceTransactions.Action.SmallInvoiceCarryover => - "small_invoice_carryover", + Action.AppliedToInvoice => "applied_to_invoice", + Action.ManualAdjustment => "manual_adjustment", + Action.ProratedRefund => "prorated_refund", + Action.RevertProratedRefund => "revert_prorated_refund", + Action.ReturnFromVoiding => "return_from_voiding", + Action.CreditNoteApplied => "credit_note_applied", + Action.CreditNoteVoided => "credit_note_voided", + Action.OverpaymentRefund => "overpayment_refund", + Action.ExternalPayment => "external_payment", + Action.SmallInvoiceCarryover => "small_invoice_carryover", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs index 01a438acc..fcb3a087a 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,5 +66,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not BalanceTransactionListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs index a0500d53c..610cef923 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public BalanceTransactionListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListPageResponse( BalanceTransactionListPageResponse balanceTransactionListPageResponse ) : base(balanceTransactionListPageResponse) { } +#pragma warning restore CS8618 public BalanceTransactionListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs index fdc3ffad9..2ddbccb66 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListParams.cs @@ -28,8 +28,12 @@ namespace Orb.Models.Customers.BalanceTransactions; /// This endpoint retrieves all customer balance transactions in reverse chronological /// order for a single customer, providing a complete audit trail of all adjustments /// and invoice applications. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BalanceTransactionListParams : ParamsBase +public record class BalanceTransactionListParams : ParamsBase { public string? CustomerID { get; init; } @@ -110,11 +114,14 @@ public DateTimeOffset? OperationTimeLte public BalanceTransactionListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListParams(BalanceTransactionListParams balanceTransactionListParams) : base(balanceTransactionListParams) { this.CustomerID = balanceTransactionListParams.CustomerID; } +#pragma warning restore CS8618 public BalanceTransactionListParams( IReadOnlyDictionary rawHeaderData, @@ -129,26 +136,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BalanceTransactionListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static BalanceTransactionListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BalanceTransactionListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -168,4 +207,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs index af2f33c65..15c27afa6 100644 --- a/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs +++ b/src/Orb/Models/Customers/BalanceTransactions/BalanceTransactionListResponse.cs @@ -157,10 +157,13 @@ public override void Validate() public BalanceTransactionListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BalanceTransactionListResponse( BalanceTransactionListResponse balanceTransactionListResponse ) : base(balanceTransactionListResponse) { } +#pragma warning restore CS8618 public BalanceTransactionListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs index e9fd5b5cd..4b682df8b 100644 --- a/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListByExternalIDParams.cs @@ -106,8 +106,12 @@ namespace Orb.Models.Customers.Costs; /// costs grouped by those matrix dimensions. Orb will return `price_groups` with /// the `grouping_key` and `secondary_grouping_key` based on the matrix price definition, /// for each `grouping_value` and `secondary_grouping_value` available. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CostListByExternalIDParams : ParamsBase +public record class CostListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -169,11 +173,14 @@ public ApiEnum? ViewMode public CostListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListByExternalIDParams(CostListByExternalIDParams costListByExternalIDParams) : base(costListByExternalIDParams) { this.ExternalCustomerID = costListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CostListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -188,24 +195,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CostListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CostListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CostListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override System::Uri Url(ClientOptions options) @@ -230,6 +274,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs b/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs index 48f209bf4..7765fd64c 100644 --- a/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Costs/CostListByExternalIDResponse.cs @@ -40,8 +40,11 @@ public override void Validate() public CostListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListByExternalIDResponse(CostListByExternalIDResponse costListByExternalIDResponse) : base(costListByExternalIDResponse) { } +#pragma warning restore CS8618 public CostListByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Costs/CostListParams.cs b/src/Orb/Models/Customers/Costs/CostListParams.cs index e87ca9141..2e328ec7d 100644 --- a/src/Orb/Models/Customers/Costs/CostListParams.cs +++ b/src/Orb/Models/Customers/Costs/CostListParams.cs @@ -106,8 +106,12 @@ namespace Orb.Models.Customers.Costs; /// costs grouped by those matrix dimensions. Orb will return `price_groups` with /// the `grouping_key` and `secondary_grouping_key` based on the matrix price definition, /// for each `grouping_value` and `secondary_grouping_value` available. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CostListParams : ParamsBase +public record class CostListParams : ParamsBase { public string? CustomerID { get; init; } @@ -167,11 +171,14 @@ public ApiEnum? ViewMode public CostListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListParams(CostListParams costListParams) : base(costListParams) { this.CustomerID = costListParams.CustomerID; } +#pragma warning restore CS8618 public CostListParams( IReadOnlyDictionary rawHeaderData, @@ -186,24 +193,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CostListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CostListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CostListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override System::Uri Url(ClientOptions options) @@ -225,6 +264,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// diff --git a/src/Orb/Models/Customers/Costs/CostListResponse.cs b/src/Orb/Models/Customers/Costs/CostListResponse.cs index 8ebf6a663..5aa7ccf33 100644 --- a/src/Orb/Models/Customers/Costs/CostListResponse.cs +++ b/src/Orb/Models/Customers/Costs/CostListResponse.cs @@ -38,8 +38,11 @@ public override void Validate() public CostListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CostListResponse(CostListResponse costListResponse) : base(costListResponse) { } +#pragma warning restore CS8618 public CostListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs index cf2bb99fa..45b80d900 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,5 +66,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not CreditListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs index d9f35364a..61ab411da 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public CreditListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDPageResponse( CreditListByExternalIDPageResponse creditListByExternalIDPageResponse ) : base(creditListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public CreditListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs index 07cec886d..a2e597622 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDParams.cs @@ -16,8 +16,17 @@ namespace Orb.Models.Customers.Credits; /// /// Note that `currency` defaults to credits if not specified. To use a real /// world currency, set `currency` to an ISO 4217 string. +/// +/// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, +/// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. +/// This filters on when the credit block becomes effective, which may differ from +/// creation time for backdated credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditListByExternalIDParams : ParamsBase +public record class CreditListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -48,6 +57,46 @@ public string? Cursor init { this._rawQueryData.Set("cursor", value); } } + public DateTimeOffset? EffectiveDateGt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gt]"); + } + init { this._rawQueryData.Set("effective_date[gt]", value); } + } + + public DateTimeOffset? EffectiveDateGte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gte]"); + } + init { this._rawQueryData.Set("effective_date[gte]", value); } + } + + public DateTimeOffset? EffectiveDateLt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lt]"); + } + init { this._rawQueryData.Set("effective_date[lt]", value); } + } + + public DateTimeOffset? EffectiveDateLte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lte]"); + } + init { this._rawQueryData.Set("effective_date[lte]", value); } + } + /// /// If set to True, all expired and depleted blocks, as well as active block /// will be returned. @@ -93,11 +142,14 @@ public long? Limit public CreditListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDParams(CreditListByExternalIDParams creditListByExternalIDParams) : base(creditListByExternalIDParams) { this.ExternalCustomerID = creditListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CreditListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -112,26 +164,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CreditListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -154,4 +243,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs index db3834dec..88039fd6d 100644 --- a/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListByExternalIDResponse.cs @@ -86,6 +86,28 @@ public required double? MaximumInitialBalance init { this._rawData.Set("maximum_initial_balance", value); } } + /// + /// User specified key-value pairs for the resource. If not present, this defaults + /// to an empty dictionary. Individual keys can be removed by setting the value + /// to `null`, and the entire metadata mapping can be cleared by setting `metadata` + /// to `null`. + /// + public required IReadOnlyDictionary Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("metadata"); + } + init + { + this._rawData.Set>( + "metadata", + FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + public required string? PerUnitCostBasis { get @@ -120,16 +142,20 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } public CreditListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDResponse( CreditListByExternalIDResponse creditListByExternalIDResponse ) : base(creditListByExternalIDResponse) { } +#pragma warning restore CS8618 public CreditListByExternalIDResponse(IReadOnlyDictionary rawData) { @@ -231,10 +257,13 @@ public override void Validate() public CreditListByExternalIDResponseFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListByExternalIDResponseFilter( CreditListByExternalIDResponseFilter creditListByExternalIDResponseFilter ) : base(creditListByExternalIDResponseFilter) { } +#pragma warning restore CS8618 public CreditListByExternalIDResponseFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListPage.cs b/src/Orb/Models/Customers/Credits/CreditListPage.cs index 0e3c9b0d5..9380ce597 100644 --- a/src/Orb/Models/Customers/Credits/CreditListPage.cs +++ b/src/Orb/Models/Customers/Credits/CreditListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not CreditListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs b/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs index 67278ba97..328236e6b 100644 --- a/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public CreditListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListPageResponse(CreditListPageResponse creditListPageResponse) : base(creditListPageResponse) { } +#pragma warning restore CS8618 public CreditListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/CreditListParams.cs b/src/Orb/Models/Customers/Credits/CreditListParams.cs index 343f39fd5..7e02bc155 100644 --- a/src/Orb/Models/Customers/Credits/CreditListParams.cs +++ b/src/Orb/Models/Customers/Credits/CreditListParams.cs @@ -16,8 +16,17 @@ namespace Orb.Models.Customers.Credits; /// /// Note that `currency` defaults to credits if not specified. To use a real /// world currency, set `currency` to an ISO 4217 string. +/// +/// Results can be filtered by the block's `effective_date` using the `effective_date[gte]`, +/// `effective_date[gt]`, `effective_date[lt]`, and `effective_date[lte]` query parameters. +/// This filters on when the credit block becomes effective, which may differ from +/// creation time for backdated credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CreditListParams : ParamsBase +public record class CreditListParams : ParamsBase { public string? CustomerID { get; init; } @@ -48,6 +57,46 @@ public string? Cursor init { this._rawQueryData.Set("cursor", value); } } + public DateTimeOffset? EffectiveDateGt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gt]"); + } + init { this._rawQueryData.Set("effective_date[gt]", value); } + } + + public DateTimeOffset? EffectiveDateGte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[gte]"); + } + init { this._rawQueryData.Set("effective_date[gte]", value); } + } + + public DateTimeOffset? EffectiveDateLt + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lt]"); + } + init { this._rawQueryData.Set("effective_date[lt]", value); } + } + + public DateTimeOffset? EffectiveDateLte + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("effective_date[lte]"); + } + init { this._rawQueryData.Set("effective_date[lte]", value); } + } + /// /// If set to True, all expired and depleted blocks, as well as active block /// will be returned. @@ -93,11 +142,14 @@ public long? Limit public CreditListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListParams(CreditListParams creditListParams) : base(creditListParams) { this.CustomerID = creditListParams.CustomerID; } +#pragma warning restore CS8618 public CreditListParams( IReadOnlyDictionary rawHeaderData, @@ -112,26 +164,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CreditListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CreditListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CreditListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -151,4 +235,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/CreditListResponse.cs b/src/Orb/Models/Customers/Credits/CreditListResponse.cs index 240ac4334..533e93329 100644 --- a/src/Orb/Models/Customers/Credits/CreditListResponse.cs +++ b/src/Orb/Models/Customers/Credits/CreditListResponse.cs @@ -53,18 +53,16 @@ public required double Balance init { this._rawData.Set("expiry_date", value); } } - public required IReadOnlyList Filters + public required IReadOnlyList Filters { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNotNullStruct>("filters"); } init { - this._rawData.Set>( + this._rawData.Set>( "filters", ImmutableArray.ToImmutableArray(value) ); @@ -81,6 +79,28 @@ public required double? MaximumInitialBalance init { this._rawData.Set("maximum_initial_balance", value); } } + /// + /// User specified key-value pairs for the resource. If not present, this defaults + /// to an empty dictionary. Individual keys can be removed by setting the value + /// to `null`, and the entire metadata mapping can be cleared by setting `metadata` + /// to `null`. + /// + public required IReadOnlyDictionary Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("metadata"); + } + init + { + this._rawData.Set>( + "metadata", + FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + public required string? PerUnitCostBasis { get @@ -91,14 +111,12 @@ public required string? PerUnitCostBasis init { this._rawData.Set("per_unit_cost_basis", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -115,14 +133,18 @@ public override void Validate() item.Validate(); } _ = this.MaximumInitialBalance; + _ = this.Metadata; _ = this.PerUnitCostBasis; this.Status.Validate(); } public CreditListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditListResponse(CreditListResponse creditListResponse) : base(creditListResponse) { } +#pragma warning restore CS8618 public CreditListResponse(IReadOnlyDictionary rawData) { @@ -156,25 +178,18 @@ public CreditListResponse FromRawUnchecked(IReadOnlyDictionary /// A PriceFilter that only allows item_id field for block filters. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Customers.Credits.Filter, - global::Orb.Models.Customers.Credits.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// /// The property of the price the block applies to. Only item_id is supported. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); + return this._rawData.GetNotNullClass>("field"); } init { this._rawData.Set("field", value); } } @@ -182,14 +197,12 @@ public sealed record class Filter : JsonModel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); + return this._rawData.GetNotNullClass>("operator"); } init { this._rawData.Set("operator", value); } } @@ -223,8 +236,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -239,35 +255,32 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Customers.Credits.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.Credits.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.Credits.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// The property of the price the block applies to. Only item_id is supported. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.FieldConverter))] +[JsonConverter(typeof(FieldConverter))] public enum Field { ItemID, } -sealed class FieldConverter : JsonConverter +sealed class FieldConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Field Read( + public override Field Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -275,22 +288,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "item_id" => global::Orb.Models.Customers.Credits.Field.ItemID, - _ => (global::Orb.Models.Customers.Credits.Field)(-1), + "item_id" => Field.ItemID, + _ => (Field)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Field value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Field.ItemID => "item_id", + Field.ItemID => "item_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -303,16 +312,16 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { Includes, Excludes, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -320,24 +329,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => global::Orb.Models.Customers.Credits.Operator.Includes, - "excludes" => global::Orb.Models.Customers.Credits.Operator.Excludes, - _ => (global::Orb.Models.Customers.Credits.Operator)(-1), + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Operator.Includes => "includes", - global::Orb.Models.Customers.Credits.Operator.Excludes => "excludes", + Operator.Includes => "includes", + Operator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -347,16 +352,16 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, PendingPayment, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -364,24 +369,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Customers.Credits.Status.Active, - "pending_payment" => global::Orb.Models.Customers.Credits.Status.PendingPayment, - _ => (global::Orb.Models.Customers.Credits.Status)(-1), + "active" => Status.Active, + "pending_payment" => Status.PendingPayment, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Status.Active => "active", - global::Orb.Models.Customers.Credits.Status.PendingPayment => "pending_payment", + Status.Active => "active", + Status.PendingPayment => "pending_payment", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs b/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs index 6457653a9..5b49ce607 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/AffectedBlock.cs @@ -73,8 +73,11 @@ public override void Validate() public AffectedBlock() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AffectedBlock(AffectedBlock affectedBlock) : base(affectedBlock) { } +#pragma warning restore CS8618 public AffectedBlock(IReadOnlyDictionary rawData) { @@ -165,8 +168,11 @@ public override void Validate() public AffectedBlockFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AffectedBlockFilter(AffectedBlockFilter affectedBlockFilter) : base(affectedBlockFilter) { } +#pragma warning restore CS8618 public AffectedBlockFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs index 3b1878b2e..d6fdce2b4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/AmendmentLedgerEntry.cs @@ -178,8 +178,11 @@ public override void Validate() public AmendmentLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AmendmentLedgerEntry(AmendmentLedgerEntry amendmentLedgerEntry) : base(amendmentLedgerEntry) { } +#pragma warning restore CS8618 public AmendmentLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs index 489750a64..1e9e7088f 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/CreditBlockExpiryLedgerEntry.cs @@ -180,8 +180,11 @@ public override void Validate() public CreditBlockExpiryLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CreditBlockExpiryLedgerEntry(CreditBlockExpiryLedgerEntry creditBlockExpiryLedgerEntry) : base(creditBlockExpiryLedgerEntry) { } +#pragma warning restore CS8618 public CreditBlockExpiryLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs index af8ec446d..663d559e4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/DecrementLedgerEntry.cs @@ -158,6 +158,11 @@ public required double StartingBalance init { this._rawData.Set("starting_balance", value); } } + /// + /// This field is deprecated and will always be null. Decrements are not associated + /// with individual events. + /// + [System::Obsolete("deprecated")] public string? EventID { get @@ -211,8 +216,11 @@ public override void Validate() public DecrementLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DecrementLedgerEntry(DecrementLedgerEntry decrementLedgerEntry) : base(decrementLedgerEntry) { } +#pragma warning restore CS8618 public DecrementLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs index 08ef51ecf..37a54c780 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/ExpirationChangeLedgerEntry.cs @@ -191,8 +191,11 @@ public override void Validate() public ExpirationChangeLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExpirationChangeLedgerEntry(ExpirationChangeLedgerEntry expirationChangeLedgerEntry) : base(expirationChangeLedgerEntry) { } +#pragma warning restore CS8618 public ExpirationChangeLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs index 8325df4e1..42cbeb6aa 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/IncrementLedgerEntry.cs @@ -202,8 +202,11 @@ public override void Validate() public IncrementLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public IncrementLedgerEntry(IncrementLedgerEntry incrementLedgerEntry) : base(incrementLedgerEntry) { } +#pragma warning restore CS8618 public IncrementLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs index 98de12804..a13d0ad42 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDParams.cs @@ -49,7 +49,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. +/// basis with the number of credit units added. If you invoice or handle payment +/// of credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in +/// the `invoice_settings` to `true` to prevent duplicate invoicing effects. * if +/// `per_unit_cost_basis` is greater than zero, an invoice will be generated and `invoice_settings` +/// must be included * if `invoice_settings` is passed, one of either `custom_due_date` +/// or `net_terms` is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -94,14 +99,14 @@ namespace Orb.Models.Customers.Credits.Ledger; /// of type `amendment`. For this entry, `block_id` is required to identify the block /// that was originally decremented from, and `amount` indicates how many credits /// to return to the customer, up to the block's initial balance. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerCreateEntryByExternalIDParams : ParamsBase +public record class LedgerCreateEntryByExternalIDParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? ExternalCustomerID { get; init; } @@ -109,16 +114,18 @@ public required LedgerCreateEntryByExternalIDParamsBody Body { get { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass( - "body" + return WrappedJsonSerializer.GetNotNullClass( + this.RawBodyData, + "RawBodyData" ); } - init { this._rawBodyData.Set("body", value); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public LedgerCreateEntryByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParams( LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams ) @@ -126,18 +133,19 @@ LedgerCreateEntryByExternalIDParams ledgerCreateEntryByExternalIDParams { this.ExternalCustomerID = ledgerCreateEntryByExternalIDParams.ExternalCustomerID; - this._rawBodyData = new(ledgerCreateEntryByExternalIDParams._rawBodyData); + this.RawBodyData = ledgerCreateEntryByExternalIDParams.RawBodyData; } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -145,27 +153,66 @@ IReadOnlyDictionary rawBodyData LedgerCreateEntryByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static LedgerCreateEntryByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData, + externalCustomerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(LedgerCreateEntryByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this.RawBodyData.Equals(other.RawBodyData); } public override System::Uri Url(ClientOptions options) @@ -199,6 +246,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(LedgerCreateEntryByExternalIDParamsBodyConverter))] @@ -357,7 +409,7 @@ public LedgerCreateEntryByExternalIDParamsBody(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -380,7 +432,7 @@ public bool TryPickIncrement( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -403,7 +455,7 @@ public bool TryPickDecrement( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -426,7 +478,7 @@ public bool TryPickExpirationChange( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -449,7 +501,7 @@ public bool TryPickVoid( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -471,7 +523,7 @@ public bool TryPickAmendment( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -482,11 +534,11 @@ public bool TryPickAmendment( /// /// /// instance.Switch( - /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} + /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} /// ); /// /// @@ -527,7 +579,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -538,11 +590,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, - /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} + /// (LedgerCreateEntryByExternalIDParamsBodyIncrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyDecrement value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyExpirationChange value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyVoid value) => {...}, + /// (LedgerCreateEntryByExternalIDParamsBodyAmendment value) => {...} /// ); /// /// @@ -617,10 +669,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryByExternalIDParamsBody? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryByExternalIDParamsBody? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -628,7 +680,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + LedgerCreateEntryByExternalIDParamsBodyIncrement _ => 0, + LedgerCreateEntryByExternalIDParamsBodyDecrement _ => 1, + LedgerCreateEntryByExternalIDParamsBodyExpirationChange _ => 2, + LedgerCreateEntryByExternalIDParamsBodyVoid _ => 3, + LedgerCreateEntryByExternalIDParamsBodyAmendment _ => 4, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyConverter @@ -664,12 +732,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -687,12 +753,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -710,12 +774,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -733,12 +795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -756,12 +816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -973,10 +1031,13 @@ public LedgerCreateEntryByExternalIDParamsBodyIncrement() this.EntryType = JsonSerializer.SerializeToElement("increment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrement( LedgerCreateEntryByExternalIDParamsBodyIncrement ledgerCreateEntryByExternalIDParamsBodyIncrement ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrement) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrement( IReadOnlyDictionary rawData @@ -1096,10 +1157,13 @@ public override void Validate() public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter( LedgerCreateEntryByExternalIDParamsBodyIncrementFilter ledgerCreateEntryByExternalIDParamsBodyIncrementFilter ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrementFilter) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrementFilter( IReadOnlyDictionary rawData @@ -1306,6 +1370,27 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// If true, the new credits purchase invoice will be marked as paid. + /// + public bool? MarkAsPaid + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mark_as_paid"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mark_as_paid", value); + } + } + /// /// An optional memo to display on the invoice. /// @@ -1324,8 +1409,8 @@ public string? Memo /// based on the invoice or issuance date, depending on the account's configured /// due date calculation method. A value of '0' here represents that the invoice /// is due on issue, whereas a value of '30' represents that the customer has - /// 30 days to pay the invoice. Do not set this field if you want to set a custom - /// due date. + /// 30 days to pay the invoice. You must set either `net_terms` or `custom_due_date`, + /// but not both. /// public long? NetTerms { @@ -1366,6 +1451,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1373,10 +1459,13 @@ public override void Validate() public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings ledgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings ) : base(ledgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettings( IReadOnlyDictionary rawData @@ -1474,7 +1563,7 @@ JsonElement element /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1495,7 +1584,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1515,7 +1604,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1526,8 +1615,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1556,7 +1645,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1567,8 +1656,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1618,10 +1707,10 @@ public override void Validate() public virtual bool Equals( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDate? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1629,7 +1718,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsCustomDueDateConverter @@ -1657,7 +1759,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1732,7 +1837,7 @@ JsonElement element /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1753,7 +1858,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1773,7 +1878,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1784,8 +1889,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1814,7 +1919,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1825,8 +1930,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1876,10 +1981,10 @@ public override void Validate() public virtual bool Equals( LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDate? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1887,7 +1992,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDParamsBodyIncrementInvoiceSettingsInvoiceDateConverter @@ -1915,7 +2033,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -2035,10 +2156,13 @@ public LedgerCreateEntryByExternalIDParamsBodyDecrement() this.EntryType = JsonSerializer.SerializeToElement("decrement"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyDecrement( LedgerCreateEntryByExternalIDParamsBodyDecrement ledgerCreateEntryByExternalIDParamsBodyDecrement ) : base(ledgerCreateEntryByExternalIDParamsBodyDecrement) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyDecrement( IReadOnlyDictionary rawData @@ -2101,9 +2225,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 +2356,13 @@ public LedgerCreateEntryByExternalIDParamsBodyExpirationChange() this.EntryType = JsonSerializer.SerializeToElement("expiration_change"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyExpirationChange( LedgerCreateEntryByExternalIDParamsBodyExpirationChange ledgerCreateEntryByExternalIDParamsBodyExpirationChange ) : base(ledgerCreateEntryByExternalIDParamsBodyExpirationChange) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyExpirationChange( IReadOnlyDictionary rawData @@ -2411,10 +2538,13 @@ public LedgerCreateEntryByExternalIDParamsBodyVoid() this.EntryType = JsonSerializer.SerializeToElement("void"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyVoid( LedgerCreateEntryByExternalIDParamsBodyVoid ledgerCreateEntryByExternalIDParamsBodyVoid ) : base(ledgerCreateEntryByExternalIDParamsBodyVoid) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyVoid( IReadOnlyDictionary rawData @@ -2610,10 +2740,13 @@ public LedgerCreateEntryByExternalIDParamsBodyAmendment() this.EntryType = JsonSerializer.SerializeToElement("amendment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryByExternalIDParamsBodyAmendment( LedgerCreateEntryByExternalIDParamsBodyAmendment ledgerCreateEntryByExternalIDParamsBodyAmendment ) : base(ledgerCreateEntryByExternalIDParamsBodyAmendment) { } +#pragma warning restore CS8618 public LedgerCreateEntryByExternalIDParamsBodyAmendment( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs index e4ad57565..195d50477 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryByExternalIDResponse.cs @@ -306,7 +306,7 @@ public LedgerCreateEntryByExternalIDResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -327,7 +327,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -348,7 +348,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -371,7 +371,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -394,7 +394,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -415,7 +415,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -438,7 +438,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -458,7 +458,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -469,13 +469,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -524,7 +524,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -535,13 +535,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -627,10 +627,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryByExternalIDResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryByExternalIDResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -638,7 +638,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerCreateEntryByExternalIDResponseConverter @@ -673,12 +691,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -695,12 +711,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -717,12 +731,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -739,12 +751,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -761,12 +771,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -783,12 +791,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -805,12 +811,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs index 47c8a79f9..07cedeafe 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryParams.cs @@ -49,7 +49,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// body of this request, Orb will also generate a one-off invoice for the customer /// for the credits pre-purchase. Note that you _must_ provide the `per_unit_cost_basis`, /// since the total charges on the invoice are calculated by multiplying the cost -/// basis with the number of credit units added. +/// basis with the number of credit units added. If you invoice or handle payment +/// of credits outside of Orb (i.e. marketplace customers), set `mark_as_paid` in +/// the `invoice_settings` to `true` to prevent duplicate invoicing effects. * if +/// `per_unit_cost_basis` is greater than zero, an invoice will be generated and `invoice_settings` +/// must be included * if `invoice_settings` is passed, one of either `custom_due_date` +/// or `net_terms` is required to determine the due date /// /// ## Deducting Credits Orb allows you to deduct credits from a customer by /// creating an entry of type `decrement`. Orb matches the algorithm for automatic @@ -94,46 +99,45 @@ namespace Orb.Models.Customers.Credits.Ledger; /// of type `amendment`. For this entry, `block_id` is required to identify the block /// that was originally decremented from, and `amount` indicates how many credits /// to return to the customer, up to the block's initial balance. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerCreateEntryParams : ParamsBase +public record class LedgerCreateEntryParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } public string? CustomerID { get; init; } public required Body Body { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("body"); - } - init { this._rawBodyData.Set("body", value); } + get { return WrappedJsonSerializer.GetNotNullClass(this.RawBodyData, "RawBodyData"); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public LedgerCreateEntryParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerCreateEntryParams(LedgerCreateEntryParams ledgerCreateEntryParams) : base(ledgerCreateEntryParams) { this.CustomerID = ledgerCreateEntryParams.CustomerID; - this._rawBodyData = new(ledgerCreateEntryParams._rawBodyData); + this.RawBodyData = ledgerCreateEntryParams.RawBodyData; } +#pragma warning restore CS8618 public LedgerCreateEntryParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -141,29 +145,63 @@ IReadOnlyDictionary rawBodyData LedgerCreateEntryParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static LedgerCreateEntryParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData, + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LedgerCreateEntryParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this.RawBodyData.Equals(other.RawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -192,6 +230,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(BodyConverter))] @@ -335,7 +378,7 @@ public Body(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -356,7 +399,7 @@ public bool TryPickIncrement([NotNullWhen(true)] out Increment? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -377,7 +420,7 @@ public bool TryPickDecrement([NotNullWhen(true)] out Decrement? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -398,7 +441,7 @@ public bool TryPickExpirationChange([NotNullWhen(true)] out ExpirationChange? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -419,7 +462,7 @@ public bool TryPickVoid([NotNullWhen(true)] out Void? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -439,7 +482,7 @@ public bool TryPickAmendment([NotNullWhen(true)] out Amendment? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -450,11 +493,11 @@ public bool TryPickAmendment([NotNullWhen(true)] out Amendment? value) /// /// /// instance.Switch( - /// (Increment value) => {...}, - /// (Decrement value) => {...}, - /// (ExpirationChange value) => {...}, - /// (Void value) => {...}, - /// (Amendment value) => {...} + /// (Increment value) => {...}, + /// (Decrement value) => {...}, + /// (ExpirationChange value) => {...}, + /// (Void value) => {...}, + /// (Amendment value) => {...} /// ); /// /// @@ -493,7 +536,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -504,11 +547,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Increment value) => {...}, - /// (Decrement value) => {...}, - /// (ExpirationChange value) => {...}, - /// (Void value) => {...}, - /// (Amendment value) => {...} + /// (Increment value) => {...}, + /// (Decrement value) => {...}, + /// (ExpirationChange value) => {...}, + /// (Void value) => {...}, + /// (Amendment value) => {...} /// ); /// /// @@ -567,10 +610,10 @@ public override void Validate() ); } - public virtual bool Equals(Body? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Body? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -578,7 +621,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Increment _ => 0, + Decrement _ => 1, + ExpirationChange _ => 2, + Void _ => 3, + Amendment _ => 4, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -609,12 +668,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -628,12 +685,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -650,12 +705,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -669,12 +722,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -688,12 +739,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -800,18 +849,16 @@ public string? Description /// Optional filter to specify which items this credit block applies to. If not /// specified, the block will apply to all items for the pricing unit. /// - public IReadOnlyList? Filters + public IReadOnlyList? Filters { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("filters"); + return this._rawData.GetNullableStruct>("filters"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "filters", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -894,8 +941,11 @@ public Increment() this.EntryType = JsonSerializer.SerializeToElement("increment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Increment(Increment increment) : base(increment) { } +#pragma warning restore CS8618 public Increment(IReadOnlyDictionary rawData) { @@ -936,25 +986,18 @@ public Increment FromRawUnchecked(IReadOnlyDictionary rawDa /// /// A PriceFilter that only allows item_id field for block filters. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Customers.Credits.Ledger.Filter, - global::Orb.Models.Customers.Credits.Ledger.FilterFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Filter : JsonModel { /// /// The property of the price the block applies to. Only item_id is supported. /// - public required ApiEnum Field + public required ApiEnum Field { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("field"); + return this._rawData.GetNotNullClass>("field"); } init { this._rawData.Set("field", value); } } @@ -962,14 +1005,12 @@ public sealed record class Filter : JsonModel /// /// Should prices that match the filter be included or excluded. /// - public required ApiEnum Operator + public required ApiEnum Operator { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("operator"); + return this._rawData.GetNotNullClass>("operator"); } init { this._rawData.Set("operator", value); } } @@ -1003,8 +1044,11 @@ public override void Validate() public Filter() { } - public Filter(global::Orb.Models.Customers.Credits.Ledger.Filter filter) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Filter(Filter filter) : base(filter) { } +#pragma warning restore CS8618 public Filter(IReadOnlyDictionary rawData) { @@ -1019,35 +1063,32 @@ public Filter(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Customers.Credits.Ledger.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Filter FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class FilterFromRaw : IFromRawJson +class FilterFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.Credits.Ledger.Filter FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.Credits.Ledger.Filter.FromRawUnchecked(rawData); + public Filter FromRawUnchecked(IReadOnlyDictionary rawData) => + Filter.FromRawUnchecked(rawData); } /// /// The property of the price the block applies to. Only item_id is supported. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.Ledger.FieldConverter))] +[JsonConverter(typeof(FieldConverter))] public enum Field { ItemID, } -sealed class FieldConverter : JsonConverter +sealed class FieldConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Ledger.Field Read( + public override Field Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1055,22 +1096,18 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "item_id" => global::Orb.Models.Customers.Credits.Ledger.Field.ItemID, - _ => (global::Orb.Models.Customers.Credits.Ledger.Field)(-1), + "item_id" => Field.ItemID, + _ => (Field)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Ledger.Field value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Field value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Ledger.Field.ItemID => "item_id", + Field.ItemID => "item_id", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1083,16 +1120,16 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(global::Orb.Models.Customers.Credits.Ledger.OperatorConverter))] +[JsonConverter(typeof(OperatorConverter))] public enum Operator { Includes, Excludes, } -sealed class OperatorConverter : JsonConverter +sealed class OperatorConverter : JsonConverter { - public override global::Orb.Models.Customers.Credits.Ledger.Operator Read( + public override Operator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1100,24 +1137,20 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => global::Orb.Models.Customers.Credits.Ledger.Operator.Includes, - "excludes" => global::Orb.Models.Customers.Credits.Ledger.Operator.Excludes, - _ => (global::Orb.Models.Customers.Credits.Ledger.Operator)(-1), + "includes" => Operator.Includes, + "excludes" => Operator.Excludes, + _ => (Operator)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Customers.Credits.Ledger.Operator value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Operator value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Customers.Credits.Ledger.Operator.Includes => "includes", - global::Orb.Models.Customers.Credits.Ledger.Operator.Excludes => "excludes", + Operator.Includes => "includes", + Operator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1192,6 +1225,27 @@ public string? ItemID init { this._rawData.Set("item_id", value); } } + /// + /// If true, the new credits purchase invoice will be marked as paid. + /// + public bool? MarkAsPaid + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("mark_as_paid"); + } + init + { + if (value == null) + { + return; + } + + this._rawData.Set("mark_as_paid", value); + } + } + /// /// An optional memo to display on the invoice. /// @@ -1210,8 +1264,8 @@ public string? Memo /// based on the invoice or issuance date, depending on the account's configured /// due date calculation method. A value of '0' here represents that the invoice /// is due on issue, whereas a value of '30' represents that the customer has - /// 30 days to pay the invoice. Do not set this field if you want to set a custom - /// due date. + /// 30 days to pay the invoice. You must set either `net_terms` or `custom_due_date`, + /// but not both. /// public long? NetTerms { @@ -1252,6 +1306,7 @@ public override void Validate() this.CustomDueDate?.Validate(); this.InvoiceDate?.Validate(); _ = this.ItemID; + _ = this.MarkAsPaid; _ = this.Memo; _ = this.NetTerms; _ = this.RequireSuccessfulPayment; @@ -1259,8 +1314,11 @@ public override void Validate() public InvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceSettings(InvoiceSettings invoiceSettings) : base(invoiceSettings) { } +#pragma warning restore CS8618 public InvoiceSettings(IReadOnlyDictionary rawData) { @@ -1339,7 +1397,7 @@ public CustomDueDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1360,7 +1418,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1380,7 +1438,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1391,8 +1449,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1421,7 +1479,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1432,8 +1490,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1475,10 +1533,10 @@ public override void Validate() } } - public virtual bool Equals(CustomDueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomDueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1486,7 +1544,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class CustomDueDateConverter : JsonConverter @@ -1513,7 +1584,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1577,7 +1651,7 @@ public InvoiceDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1598,7 +1672,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1618,7 +1692,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1629,8 +1703,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1657,7 +1731,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1668,8 +1742,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -1709,10 +1783,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1720,7 +1794,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter @@ -1747,7 +1834,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1862,8 +1952,11 @@ public Decrement() this.EntryType = JsonSerializer.SerializeToElement("decrement"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Decrement(Decrement decrement) : base(decrement) { } +#pragma warning restore CS8618 public Decrement(IReadOnlyDictionary rawData) { @@ -1915,9 +2008,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 +2139,11 @@ public ExpirationChange() this.EntryType = JsonSerializer.SerializeToElement("expiration_change"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExpirationChange(ExpirationChange expirationChange) : base(expirationChange) { } +#pragma warning restore CS8618 public ExpirationChange(IReadOnlyDictionary rawData) { @@ -2210,8 +2306,11 @@ public Void() this.EntryType = JsonSerializer.SerializeToElement("void"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Void(Void void_) : base(void_) { } +#pragma warning restore CS8618 public Void(IReadOnlyDictionary rawData) { @@ -2395,8 +2494,11 @@ public Amendment() this.EntryType = JsonSerializer.SerializeToElement("amendment"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amendment(Amendment amendment) : base(amendment) { } +#pragma warning restore CS8618 public Amendment(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs index b579876c4..2c61f6998 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerCreateEntryResponse.cs @@ -291,7 +291,7 @@ public LedgerCreateEntryResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -312,7 +312,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -333,7 +333,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -356,7 +356,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -379,7 +379,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -400,7 +400,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -423,7 +423,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -443,7 +443,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -454,13 +454,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -509,7 +509,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -520,13 +520,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -605,10 +605,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerCreateEntryResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerCreateEntryResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -616,7 +616,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerCreateEntryResponseConverter : JsonConverter @@ -650,12 +668,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -672,12 +688,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -694,12 +708,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -716,12 +728,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -738,12 +748,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -760,12 +768,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -782,12 +788,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs index f4ed0b2ba..056857986 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,5 +66,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not LedgerListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs index 5bda979ed..33a90f0d4 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public LedgerListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListByExternalIDPageResponse( LedgerListByExternalIDPageResponse ledgerListByExternalIDPageResponse ) : base(ledgerListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public LedgerListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs index e2c4466b5..6b5677d2b 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListByExternalIDParams : ParamsBase +public record class LedgerListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -206,11 +207,14 @@ public string? MinimumAmount public LedgerListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListByExternalIDParams(LedgerListByExternalIDParams ledgerListByExternalIDParams) : base(ledgerListByExternalIDParams) { this.ExternalCustomerID = ledgerListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public LedgerListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -225,24 +229,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] LedgerListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static LedgerListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(LedgerListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override System::Uri Url(ClientOptions options) @@ -267,6 +308,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(LedgerListByExternalIDParamsEntryStatusConverter))] diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs index 08954b4cd..f60fa2ac7 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListByExternalIDResponse.cs @@ -297,7 +297,7 @@ public LedgerListByExternalIDResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -318,7 +318,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -339,7 +339,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -362,7 +362,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -385,7 +385,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -406,7 +406,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -429,7 +429,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -449,7 +449,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -460,13 +460,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -515,7 +515,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -526,13 +526,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -615,10 +615,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerListByExternalIDResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerListByExternalIDResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -626,7 +626,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerListByExternalIDResponseConverter : JsonConverter @@ -660,12 +678,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -682,12 +698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -704,12 +718,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -726,12 +738,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -748,12 +758,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -770,12 +778,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -792,12 +798,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs index 2fd61302a..7aa4cae8a 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not LedgerListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs index 374ccf577..9170fdbe1 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public LedgerListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListPageResponse(LedgerListPageResponse ledgerListPageResponse) : base(ledgerListPageResponse) { } +#pragma warning restore CS8618 public LedgerListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs index 6e6519a41..ddff956f6 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListParams.cs @@ -31,11 +31,8 @@ namespace Orb.Models.Customers.Credits.Ledger; /// /// As usage for a customer is reported into Orb, credits may be deducted according /// to the customer's plan configuration. An automated deduction of this type will -/// result in a ledger entry, also with a starting and ending balance. In order to -/// provide better tracing capabilities for automatic deductions, Orb always associates -/// each automatic deduction with the `event_id` at the time of ingestion, used to -/// pinpoint _why_ credit deduction took place and to ensure that credits are never -/// deducted without an associated usage event. +/// result in a ledger entry, also with a starting and ending balance. Each day's +/// usage for a particular price, invoice, and block will be grouped into a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the *soonest /// expiring credit block* first in order to ensure that all credits are utilized @@ -77,8 +74,12 @@ namespace Orb.Models.Customers.Credits.Ledger; /// ## Amendment When credits are added to a customer's balance as a result /// of a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class LedgerListParams : ParamsBase +public record class LedgerListParams : ParamsBase { public string? CustomerID { get; init; } @@ -204,11 +205,14 @@ public string? MinimumAmount public LedgerListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public LedgerListParams(LedgerListParams ledgerListParams) : base(ledgerListParams) { this.CustomerID = ledgerListParams.CustomerID; } +#pragma warning restore CS8618 public LedgerListParams( IReadOnlyDictionary rawHeaderData, @@ -223,24 +227,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] LedgerListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static LedgerListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(LedgerListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override System::Uri Url(ClientOptions options) @@ -262,6 +298,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(EntryStatusConverter))] diff --git a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs index 840a5e070..7e02c1afb 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/LedgerListResponse.cs @@ -288,7 +288,7 @@ public LedgerListResponse(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -309,7 +309,7 @@ public bool TryPickIncrementLedgerEntry([NotNullWhen(true)] out IncrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -330,7 +330,7 @@ public bool TryPickDecrementLedgerEntry([NotNullWhen(true)] out DecrementLedgerE /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -353,7 +353,7 @@ public bool TryPickExpirationChangeLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -376,7 +376,7 @@ public bool TryPickCreditBlockExpiryLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -397,7 +397,7 @@ public bool TryPickVoidLedgerEntry([NotNullWhen(true)] out VoidLedgerEntry? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -420,7 +420,7 @@ public bool TryPickVoidInitiatedLedgerEntry( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -440,7 +440,7 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -451,13 +451,13 @@ public bool TryPickAmendmentLedgerEntry([NotNullWhen(true)] out AmendmentLedgerE /// /// /// instance.Switch( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -506,7 +506,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -517,13 +517,13 @@ public void Switch( /// /// /// var result = instance.Match( - /// (IncrementLedgerEntry value) => {...}, - /// (DecrementLedgerEntry value) => {...}, - /// (ExpirationChangeLedgerEntry value) => {...}, - /// (CreditBlockExpiryLedgerEntry value) => {...}, - /// (VoidLedgerEntry value) => {...}, - /// (VoidInitiatedLedgerEntry value) => {...}, - /// (AmendmentLedgerEntry value) => {...} + /// (IncrementLedgerEntry value) => {...}, + /// (DecrementLedgerEntry value) => {...}, + /// (ExpirationChangeLedgerEntry value) => {...}, + /// (CreditBlockExpiryLedgerEntry value) => {...}, + /// (VoidLedgerEntry value) => {...}, + /// (VoidInitiatedLedgerEntry value) => {...}, + /// (AmendmentLedgerEntry value) => {...} /// ); /// /// @@ -599,10 +599,10 @@ public override void Validate() ); } - public virtual bool Equals(LedgerListResponse? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(LedgerListResponse? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -610,7 +610,25 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + IncrementLedgerEntry _ => 0, + DecrementLedgerEntry _ => 1, + ExpirationChangeLedgerEntry _ => 2, + CreditBlockExpiryLedgerEntry _ => 3, + VoidLedgerEntry _ => 4, + VoidInitiatedLedgerEntry _ => 5, + AmendmentLedgerEntry _ => 6, + _ => -1, + }; + } } sealed class LedgerListResponseConverter : JsonConverter @@ -644,12 +662,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -666,12 +682,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -688,12 +702,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -710,12 +722,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -732,12 +742,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -754,12 +762,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -776,12 +782,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs index af6fb1fcf..6190085d9 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/VoidInitiatedLedgerEntry.cs @@ -213,8 +213,11 @@ public override void Validate() public VoidInitiatedLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VoidInitiatedLedgerEntry(VoidInitiatedLedgerEntry voidInitiatedLedgerEntry) : base(voidInitiatedLedgerEntry) { } +#pragma warning restore CS8618 public VoidInitiatedLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs b/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs index dc391a7b7..30047428c 100644 --- a/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs +++ b/src/Orb/Models/Customers/Credits/Ledger/VoidLedgerEntry.cs @@ -200,8 +200,11 @@ public override void Validate() public VoidLedgerEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VoidLedgerEntry(VoidLedgerEntry voidLedgerEntry) : base(voidLedgerEntry) { } +#pragma warning restore CS8618 public VoidLedgerEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs index c260d51ff..f50792375 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDParams.cs @@ -18,8 +18,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// If a top-up already exists for this customer in the same currency, the existing /// top-up will be replaced. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpCreateByExternalIDParams : ParamsBase +public record class TopUpCreateByExternalIDParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -143,6 +147,8 @@ public ApiEnum? ExpiresAf public TopUpCreateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDParams( TopUpCreateByExternalIDParams topUpCreateByExternalIDParams ) @@ -152,6 +158,7 @@ TopUpCreateByExternalIDParams topUpCreateByExternalIDParams this._rawBodyData = new(topUpCreateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public TopUpCreateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -169,29 +176,68 @@ IReadOnlyDictionary rawBodyData TopUpCreateByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static TopUpCreateByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalCustomerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpCreateByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -223,6 +269,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -313,10 +364,13 @@ public override void Validate() public TopUpCreateByExternalIDParamsInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDParamsInvoiceSettings( TopUpCreateByExternalIDParamsInvoiceSettings topUpCreateByExternalIDParamsInvoiceSettings ) : base(topUpCreateByExternalIDParamsInvoiceSettings) { } +#pragma warning restore CS8618 public TopUpCreateByExternalIDParamsInvoiceSettings( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs index 3dac5357b..c947f056f 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateByExternalIDResponse.cs @@ -138,10 +138,13 @@ public override void Validate() public TopUpCreateByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateByExternalIDResponse( TopUpCreateByExternalIDResponse topUpCreateByExternalIDResponse ) : base(topUpCreateByExternalIDResponse) { } +#pragma warning restore CS8618 public TopUpCreateByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs index 3d1ff3c2d..8b07a3ef9 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateParams.cs @@ -18,8 +18,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// If a top-up already exists for this customer in the same currency, the existing /// top-up will be replaced. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpCreateParams : ParamsBase +public record class TopUpCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -141,6 +145,8 @@ public ApiEnum? ExpiresAfterUnit public TopUpCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateParams(TopUpCreateParams topUpCreateParams) : base(topUpCreateParams) { @@ -148,6 +154,7 @@ public TopUpCreateParams(TopUpCreateParams topUpCreateParams) this._rawBodyData = new(topUpCreateParams._rawBodyData); } +#pragma warning restore CS8618 public TopUpCreateParams( IReadOnlyDictionary rawHeaderData, @@ -165,29 +172,63 @@ IReadOnlyDictionary rawBodyData TopUpCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static TopUpCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(TopUpCreateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -216,6 +257,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -301,8 +347,11 @@ public override void Validate() public InvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceSettings(InvoiceSettings invoiceSettings) : base(invoiceSettings) { } +#pragma warning restore CS8618 public InvoiceSettings(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs index 0342bbe41..d3e3630b8 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpCreateResponse.cs @@ -133,8 +133,11 @@ public override void Validate() public TopUpCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpCreateResponse(TopUpCreateResponse topUpCreateResponse) : base(topUpCreateResponse) { } +#pragma warning restore CS8618 public TopUpCreateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs index 67c920def..5e57a66cf 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteByExternalIDParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// This deactivates the top-up and voids any invoices associated with pending credit /// blocks purchased through the top-up. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpDeleteByExternalIDParams : ParamsBase +public record class TopUpDeleteByExternalIDParams : ParamsBase { public required string ExternalCustomerID { get; init; } @@ -20,6 +24,8 @@ public sealed record class TopUpDeleteByExternalIDParams : ParamsBase public TopUpDeleteByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpDeleteByExternalIDParams( TopUpDeleteByExternalIDParams topUpDeleteByExternalIDParams ) @@ -28,6 +34,7 @@ TopUpDeleteByExternalIDParams topUpDeleteByExternalIDParams this.ExternalCustomerID = topUpDeleteByExternalIDParams.ExternalCustomerID; this.TopUpID = topUpDeleteByExternalIDParams.TopUpID; } +#pragma warning restore CS8618 public TopUpDeleteByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -42,24 +49,64 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpDeleteByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID, + string topUpID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; + this.TopUpID = topUpID; } #pragma warning restore CS8618 - /// + /// public static TopUpDeleteByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID, + string topUpID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID, + topUpID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["TopUpID"] = JsonSerializer.SerializeToElement(this.TopUpID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(TopUpDeleteByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return this.ExternalCustomerID.Equals(other.ExternalCustomerID) + && (this.TopUpID?.Equals(other.TopUpID) ?? other.TopUpID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -85,4 +132,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs index 581c2ebdd..d2d2c0576 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpDeleteParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// This deactivates the top-up and voids any invoices associated with pending credit /// blocks purchased through the top-up. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpDeleteParams : ParamsBase +public record class TopUpDeleteParams : ParamsBase { public required string CustomerID { get; init; } @@ -20,12 +24,15 @@ public sealed record class TopUpDeleteParams : ParamsBase public TopUpDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpDeleteParams(TopUpDeleteParams topUpDeleteParams) : base(topUpDeleteParams) { this.CustomerID = topUpDeleteParams.CustomerID; this.TopUpID = topUpDeleteParams.TopUpID; } +#pragma warning restore CS8618 public TopUpDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -40,24 +47,62 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID, + string topUpID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; + this.TopUpID = topUpID; } #pragma warning restore CS8618 - /// + /// public static TopUpDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID, + string topUpID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID, + topUpID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["TopUpID"] = JsonSerializer.SerializeToElement(this.TopUpID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(TopUpDeleteParams? other) + { + if (other == null) + { + return false; + } + return this.CustomerID.Equals(other.CustomerID) + && (this.TopUpID?.Equals(other.TopUpID) ?? other.TopUpID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -79,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs index c40b7b227..e7ec8a8f8 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpInvoiceSettings.cs @@ -87,8 +87,11 @@ public override void Validate() public TopUpInvoiceSettings() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpInvoiceSettings(TopUpInvoiceSettings topUpInvoiceSettings) : base(topUpInvoiceSettings) { } +#pragma warning restore CS8618 public TopUpInvoiceSettings(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs index 78aa63b2c..7abeb4ac9 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not TopUpListByExternalIDPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs index a5f35dcab..3d857a2e2 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDPageResponse.cs @@ -56,10 +56,13 @@ public override void Validate() public TopUpListByExternalIDPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDPageResponse( TopUpListByExternalIDPageResponse topUpListByExternalIDPageResponse ) : base(topUpListByExternalIDPageResponse) { } +#pragma warning restore CS8618 public TopUpListByExternalIDPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs index 4ea1cbcfc..c30ab15fd 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// List top-ups by external ID +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpListByExternalIDParams : ParamsBase +public record class TopUpListByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } @@ -52,11 +56,14 @@ public long? Limit public TopUpListByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDParams(TopUpListByExternalIDParams topUpListByExternalIDParams) : base(topUpListByExternalIDParams) { this.ExternalCustomerID = topUpListByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public TopUpListByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -71,24 +78,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpListByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static TopUpListByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(TopUpListByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -113,4 +157,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs index 8af7cb784..b13179e16 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListByExternalIDResponse.cs @@ -135,10 +135,13 @@ public override void Validate() public TopUpListByExternalIDResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListByExternalIDResponse( TopUpListByExternalIDResponse topUpListByExternalIDResponse ) : base(topUpListByExternalIDResponse) { } +#pragma warning restore CS8618 public TopUpListByExternalIDResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs index e35ea6aed..3fa1dfdcb 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not TopUpListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs index 70a6d2c75..3768fe050 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public TopUpListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListPageResponse(TopUpListPageResponse topUpListPageResponse) : base(topUpListPageResponse) { } +#pragma warning restore CS8618 public TopUpListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs index affa167c2..290592e35 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Customers.Credits.TopUps; /// /// List top-ups +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class TopUpListParams : ParamsBase +public record class TopUpListParams : ParamsBase { public string? CustomerID { get; init; } @@ -52,11 +56,14 @@ public long? Limit public TopUpListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListParams(TopUpListParams topUpListParams) : base(topUpListParams) { this.CustomerID = topUpListParams.CustomerID; } +#pragma warning restore CS8618 public TopUpListParams( IReadOnlyDictionary rawHeaderData, @@ -71,24 +78,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] TopUpListParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static TopUpListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(TopUpListParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -110,4 +149,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs b/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs index bd8a54a0f..9b6422446 100644 --- a/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs +++ b/src/Orb/Models/Customers/Credits/TopUps/TopUpListResponse.cs @@ -133,8 +133,11 @@ public override void Validate() public TopUpListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TopUpListResponse(TopUpListResponse topUpListResponse) : base(topUpListResponse) { } +#pragma warning restore CS8618 public TopUpListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/Customer.cs b/src/Orb/Models/Customers/Customer.cs index 286d65f48..b74b276bd 100644 --- a/src/Orb/Models/Customers/Customer.cs +++ b/src/Orb/Models/Customers/Customer.cs @@ -350,31 +350,32 @@ public required Address? ShippingAddress /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public required CustomerTaxID? TaxID { @@ -487,8 +488,11 @@ public override void Validate() public Customer() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Customer(Customer customer) : base(customer) { } +#pragma warning restore CS8618 public Customer(IReadOnlyDictionary rawData) { @@ -561,8 +565,11 @@ public override void Validate() public Hierarchy() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Hierarchy(Hierarchy hierarchy) : base(hierarchy) { } +#pragma warning restore CS8618 public Hierarchy(IReadOnlyDictionary rawData) { @@ -603,6 +610,7 @@ public enum CustomerPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerPaymentProviderConverter : JsonConverter @@ -620,6 +628,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerPaymentProvider.StripeCharge, "stripe_invoice" => CustomerPaymentProvider.StripeInvoice, "netsuite" => CustomerPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerPaymentProvider.NetsuiteAmpersand, _ => (CustomerPaymentProvider)(-1), }; } @@ -639,6 +648,7 @@ JsonSerializerOptions options CustomerPaymentProvider.StripeCharge => "stripe_charge", CustomerPaymentProvider.StripeInvoice => "stripe_invoice", CustomerPaymentProvider.Netsuite => "netsuite", + CustomerPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -693,8 +703,11 @@ public override void Validate() public AccountingSyncConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingSyncConfiguration(AccountingSyncConfiguration accountingSyncConfiguration) : base(accountingSyncConfiguration) { } +#pragma warning restore CS8618 public AccountingSyncConfiguration(IReadOnlyDictionary rawData) { @@ -760,8 +773,11 @@ public override void Validate() public AccountingProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AccountingProvider(AccountingProvider accountingProvider) : base(accountingProvider) { } +#pragma warning restore CS8618 public AccountingProvider(IReadOnlyDictionary rawData) { @@ -797,6 +813,7 @@ public enum AccountingProviderProviderType { Quickbooks, Netsuite, + NetsuiteAmpersand, } sealed class AccountingProviderProviderTypeConverter : JsonConverter @@ -811,6 +828,7 @@ JsonSerializerOptions options { "quickbooks" => AccountingProviderProviderType.Quickbooks, "netsuite" => AccountingProviderProviderType.Netsuite, + "netsuite_ampersand" => AccountingProviderProviderType.NetsuiteAmpersand, _ => (AccountingProviderProviderType)(-1), }; } @@ -827,6 +845,7 @@ JsonSerializerOptions options { AccountingProviderProviderType.Quickbooks => "quickbooks", AccountingProviderProviderType.Netsuite => "netsuite", + AccountingProviderProviderType.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -882,8 +901,11 @@ public override void Validate() public CustomerPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerPaymentConfiguration(CustomerPaymentConfiguration customerPaymentConfiguration) : base(customerPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerPaymentConfiguration(IReadOnlyDictionary rawData) { @@ -941,6 +963,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -975,15 +1012,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerPaymentConfigurationPaymentProvider( CustomerPaymentConfigurationPaymentProvider customerPaymentConfigurationPaymentProvider ) : base(customerPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -1093,8 +1134,11 @@ public override void Validate() public ReportingConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ReportingConfiguration(ReportingConfiguration reportingConfiguration) : base(reportingConfiguration) { } +#pragma warning restore CS8618 public ReportingConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerCreateParams.cs b/src/Orb/Models/Customers/CustomerCreateParams.cs index f548db5bd..698879ff1 100644 --- a/src/Orb/Models/Customers/CustomerCreateParams.cs +++ b/src/Orb/Models/Customers/CustomerCreateParams.cs @@ -22,8 +22,12 @@ namespace Orb.Models.Customers; /// to automatically issue invoices * [Customer ID Aliases](/events-and-metrics/customer-aliases) /// can be configured by setting `external_customer_id` * [Timezone localization](/essentials/timezones) /// can be configured on a per-customer basis by setting the `timezone` parameter +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerCreateParams : ParamsBase +public record class CustomerCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -364,31 +368,32 @@ public TaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public CustomerTaxID? TaxID { @@ -417,11 +422,14 @@ public string? Timezone public CustomerCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerCreateParams(CustomerCreateParams customerCreateParams) : base(customerCreateParams) { this._rawBodyData = new(customerCreateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerCreateParams( IReadOnlyDictionary rawHeaderData, @@ -448,7 +456,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static CustomerCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -462,6 +470,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/customers") @@ -487,6 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -499,14 +540,14 @@ public sealed record class PaymentConfiguration : JsonModel /// /// Provider-specific payment configuration. /// - public IReadOnlyList? PaymentProviders + public IReadOnlyList? PaymentProviders { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("payment_providers"); + return this._rawData.GetNullableStruct>( + "payment_providers" + ); } init { @@ -515,7 +556,7 @@ public sealed record class PaymentConfiguration : JsonModel return; } - this._rawData.Set?>( + this._rawData.Set?>( "payment_providers", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -533,8 +574,11 @@ public override void Validate() public PaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PaymentConfiguration(PaymentConfiguration paymentConfiguration) : base(paymentConfiguration) { } +#pragma warning restore CS8618 public PaymentConfiguration(IReadOnlyDictionary rawData) { @@ -566,9 +610,7 @@ IReadOnlyDictionary rawData ) => PaymentConfiguration.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentProvider : JsonModel { /// @@ -584,6 +626,21 @@ public required ApiEnum ProviderType init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -618,13 +675,17 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public PaymentProvider() { } - public PaymentProvider(global::Orb.Models.Customers.PaymentProvider paymentProvider) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PaymentProvider(PaymentProvider paymentProvider) : base(paymentProvider) { } +#pragma warning restore CS8618 public PaymentProvider(IReadOnlyDictionary rawData) { @@ -640,9 +701,7 @@ public PaymentProvider(IReadOnlyDictionary rawData) #pragma warning restore CS8618 /// - public static global::Orb.Models.Customers.PaymentProvider FromRawUnchecked( - IReadOnlyDictionary rawData - ) + public static PaymentProvider FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } @@ -655,12 +714,11 @@ public PaymentProvider(ApiEnum providerType) } } -class PaymentProviderFromRaw : IFromRawJson +class PaymentProviderFromRaw : IFromRawJson { /// - public global::Orb.Models.Customers.PaymentProvider FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Customers.PaymentProvider.FromRawUnchecked(rawData); + public PaymentProvider FromRawUnchecked(IReadOnlyDictionary rawData) => + PaymentProvider.FromRawUnchecked(rawData); } /// @@ -719,6 +777,7 @@ public enum CustomerCreateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerCreateParamsPaymentProviderConverter @@ -737,6 +796,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerCreateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerCreateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerCreateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerCreateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerCreateParamsPaymentProvider)(-1), }; } @@ -756,6 +816,7 @@ JsonSerializerOptions options CustomerCreateParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerCreateParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerCreateParamsPaymentProvider.Netsuite => "netsuite", + CustomerCreateParamsPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -858,7 +919,7 @@ public TaxConfiguration(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -879,7 +940,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -900,7 +961,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -921,7 +982,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -942,7 +1003,7 @@ public bool TryPickNumeral([NotNullWhen(true)] out Numeral? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -963,7 +1024,7 @@ public bool TryPickAnrok([NotNullWhen(true)] out Anrok? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -983,7 +1044,7 @@ public bool TryPickStripe([NotNullWhen(true)] out Stripe? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -994,12 +1055,12 @@ public bool TryPickStripe([NotNullWhen(true)] out Stripe? value) /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (Numeral value) => {...}, - /// (Anrok value) => {...}, - /// (Stripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (Numeral value) => {...}, + /// (Anrok value) => {...}, + /// (Stripe value) => {...} /// ); /// /// @@ -1044,7 +1105,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1055,12 +1116,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (Numeral value) => {...}, - /// (Anrok value) => {...}, - /// (Stripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (Numeral value) => {...}, + /// (Anrok value) => {...}, + /// (Stripe value) => {...} /// ); /// /// @@ -1127,10 +1188,10 @@ public override void Validate() ); } - public virtual bool Equals(TaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1138,7 +1199,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + Numeral _ => 3, + Anrok _ => 4, + Stripe _ => 5, + _ => -1, + }; + } } sealed class TaxConfigurationConverter : JsonConverter @@ -1172,12 +1250,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1194,12 +1270,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1216,12 +1290,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1235,12 +1307,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1254,12 +1324,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1273,12 +1341,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1355,8 +1421,11 @@ public Numeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Numeral(Numeral numeral) : base(numeral) { } +#pragma warning restore CS8618 public Numeral(IReadOnlyDictionary rawData) { @@ -1447,8 +1516,11 @@ public Anrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Anrok(Anrok anrok) : base(anrok) { } +#pragma warning restore CS8618 public Anrok(IReadOnlyDictionary rawData) { @@ -1539,8 +1611,11 @@ public Stripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Stripe(Stripe stripe) : base(stripe) { } +#pragma warning restore CS8618 public Stripe(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerDeleteParams.cs b/src/Orb/Models/Customers/CustomerDeleteParams.cs index 9ea9ff627..8cb4e6288 100644 --- a/src/Orb/Models/Customers/CustomerDeleteParams.cs +++ b/src/Orb/Models/Customers/CustomerDeleteParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.Customers; /// take a few minutes to propagate to related resources. However, querying for the /// customer on subsequent GET requests while deletion is in process will reflect /// its deletion. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerDeleteParams : ParamsBase +public record class CustomerDeleteParams : ParamsBase { public string? CustomerID { get; init; } public CustomerDeleteParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerDeleteParams(CustomerDeleteParams customerDeleteParams) : base(customerDeleteParams) { this.CustomerID = customerDeleteParams.CustomerID; } +#pragma warning restore CS8618 public CustomerDeleteParams( IReadOnlyDictionary rawHeaderData, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerDeleteParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerDeleteParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerDeleteParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs index 567a20645..2f2842a1f 100644 --- a/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchByExternalIDParams.cs @@ -13,13 +13,19 @@ namespace Orb.Models.Customers; /// (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). /// /// Note that the resource and semantics of this endpoint exactly mirror [Get Customer](fetch-customer). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerFetchByExternalIDParams : ParamsBase +public record class CustomerFetchByExternalIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } public CustomerFetchByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerFetchByExternalIDParams( CustomerFetchByExternalIDParams customerFetchByExternalIDParams ) @@ -27,6 +33,7 @@ CustomerFetchByExternalIDParams customerFetchByExternalIDParams { this.ExternalCustomerID = customerFetchByExternalIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CustomerFetchByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -41,26 +48,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerFetchByExternalIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CustomerFetchByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerFetchByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -80,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerFetchParams.cs b/src/Orb/Models/Customers/CustomerFetchParams.cs index df3020ce6..3933122d4 100644 --- a/src/Orb/Models/Customers/CustomerFetchParams.cs +++ b/src/Orb/Models/Customers/CustomerFetchParams.cs @@ -15,18 +15,25 @@ namespace Orb.Models.Customers; /// /// See the [Customer resource](/core-concepts#customer) for a full discussion /// of the Customer model. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerFetchParams : ParamsBase +public record class CustomerFetchParams : ParamsBase { public string? CustomerID { get; init; } public CustomerFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerFetchParams(CustomerFetchParams customerFetchParams) : base(customerFetchParams) { this.CustomerID = customerFetchParams.CustomerID; } +#pragma warning restore CS8618 public CustomerFetchParams( IReadOnlyDictionary rawHeaderData, @@ -41,26 +48,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -80,4 +119,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerHierarchyConfig.cs b/src/Orb/Models/Customers/CustomerHierarchyConfig.cs index 2445c7712..22de7b71f 100644 --- a/src/Orb/Models/Customers/CustomerHierarchyConfig.cs +++ b/src/Orb/Models/Customers/CustomerHierarchyConfig.cs @@ -59,8 +59,11 @@ public override void Validate() public CustomerHierarchyConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerHierarchyConfig(CustomerHierarchyConfig customerHierarchyConfig) : base(customerHierarchyConfig) { } +#pragma warning restore CS8618 public CustomerHierarchyConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerListPage.cs b/src/Orb/Models/Customers/CustomerListPage.cs index 994b7ca0a..ff7eb3360 100644 --- a/src/Orb/Models/Customers/CustomerListPage.cs +++ b/src/Orb/Models/Customers/CustomerListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -62,5 +63,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not CustomerListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Customers/CustomerListPageResponse.cs b/src/Orb/Models/Customers/CustomerListPageResponse.cs index 0faa054f7..4dcf9da9f 100644 --- a/src/Orb/Models/Customers/CustomerListPageResponse.cs +++ b/src/Orb/Models/Customers/CustomerListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public CustomerListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerListPageResponse(CustomerListPageResponse customerListPageResponse) : base(customerListPageResponse) { } +#pragma warning restore CS8618 public CustomerListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/CustomerListParams.cs b/src/Orb/Models/Customers/CustomerListParams.cs index aa88c2b67..ff31d7dce 100644 --- a/src/Orb/Models/Customers/CustomerListParams.cs +++ b/src/Orb/Models/Customers/CustomerListParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Customers; /// Orb's [standardized pagination format](/api-reference/pagination). /// /// See [Customer](/core-concepts##customer) for an overview of the customer model. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerListParams : ParamsBase +public record class CustomerListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -94,8 +98,11 @@ public long? Limit public CustomerListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerListParams(CustomerListParams customerListParams) : base(customerListParams) { } +#pragma warning restore CS8618 public CustomerListParams( IReadOnlyDictionary rawHeaderData, @@ -118,7 +125,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static CustomerListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -130,6 +137,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/customers") @@ -146,4 +179,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs index 333276063..97d02ac07 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.cs @@ -15,14 +15,19 @@ namespace Orb.Models.Customers; /// to be charged, ensuring that the most up-to-date payment method is charged. /// /// **Note**: This functionality is currently only available for Stripe. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams - : ParamsBase +public record class CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams : ParamsBase { public string? ExternalCustomerID { get; init; } public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams customerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams ) @@ -31,6 +36,7 @@ CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams customerSyncPaym this.ExternalCustomerID = customerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams.ExternalCustomerID; } +#pragma warning restore CS8618 public CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( IReadOnlyDictionary rawHeaderData, @@ -45,24 +51,63 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalCustomerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalCustomerID = externalCustomerID; } #pragma warning restore CS8618 - /// + /// public static CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalCustomerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalCustomerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalCustomerID"] = JsonSerializer.SerializeToElement( + this.ExternalCustomerID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals( + CustomerSyncPaymentMethodsFromGatewayByExternalCustomerIDParams? other + ) + { + if (other == null) + { + return false; + } + return ( + this.ExternalCustomerID?.Equals(other.ExternalCustomerID) + ?? other.ExternalCustomerID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -87,4 +132,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs index b48588ffb..fd5f3d6b4 100644 --- a/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs +++ b/src/Orb/Models/Customers/CustomerSyncPaymentMethodsFromGatewayParams.cs @@ -15,13 +15,19 @@ namespace Orb.Models.Customers; /// to be charged, ensuring that the most up-to-date payment method is charged. /// /// **Note**: This functionality is currently only available for Stripe. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerSyncPaymentMethodsFromGatewayParams : ParamsBase +public record class CustomerSyncPaymentMethodsFromGatewayParams : ParamsBase { public string? CustomerID { get; init; } public CustomerSyncPaymentMethodsFromGatewayParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerSyncPaymentMethodsFromGatewayParams( CustomerSyncPaymentMethodsFromGatewayParams customerSyncPaymentMethodsFromGatewayParams ) @@ -29,6 +35,7 @@ CustomerSyncPaymentMethodsFromGatewayParams customerSyncPaymentMethodsFromGatewa { this.CustomerID = customerSyncPaymentMethodsFromGatewayParams.CustomerID; } +#pragma warning restore CS8618 public CustomerSyncPaymentMethodsFromGatewayParams( IReadOnlyDictionary rawHeaderData, @@ -43,26 +50,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] CustomerSyncPaymentMethodsFromGatewayParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerSyncPaymentMethodsFromGatewayParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + customerID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(CustomerSyncPaymentMethodsFromGatewayParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -82,4 +121,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs index cdaab38bd..2bfe546a3 100644 --- a/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateByExternalIDParams.cs @@ -16,8 +16,12 @@ namespace Orb.Models.Customers; /// This endpoint is used to update customer details given an `external_customer_id` /// (see [Customer ID Aliases](/events-and-metrics/customer-aliases)). Note that the /// resource and semantics of this endpoint exactly mirror [Update Customer](update-customer). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerUpdateByExternalIDParams : ParamsBase +public record class CustomerUpdateByExternalIDParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -103,7 +107,8 @@ public AddressInput? BillingAddress /// /// An ISO 4217 currency string used for the customer's invoices and balance. - /// If not set at creation time, will be set at subscription creation time. + /// This can only be set if the customer does not already have a currency configured. + /// If not set at creation or update time, it will be set at subscription creation time. /// public string? Currency { @@ -365,31 +370,32 @@ public CustomerUpdateByExternalIDParamsTaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public CustomerTaxID? TaxID { @@ -403,6 +409,8 @@ public CustomerTaxID? TaxID public CustomerUpdateByExternalIDParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParams( CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams ) @@ -412,6 +420,7 @@ CustomerUpdateByExternalIDParams customerUpdateByExternalIDParams this._rawBodyData = new(customerUpdateByExternalIDParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParams( IReadOnlyDictionary rawHeaderData, @@ -429,27 +438,61 @@ IReadOnlyDictionary rawBodyData CustomerUpdateByExternalIDParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string id ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ID = id; } #pragma warning restore CS8618 - /// + /// public static CustomerUpdateByExternalIDParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string id ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + id + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ID"] = JsonSerializer.SerializeToElement(this.ID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CustomerUpdateByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return (this.ID?.Equals(other.ID) ?? other.ID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override System::Uri Url(ClientOptions options) @@ -480,6 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -531,10 +579,13 @@ public override void Validate() public CustomerUpdateByExternalIDParamsPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsPaymentConfiguration( CustomerUpdateByExternalIDParamsPaymentConfiguration customerUpdateByExternalIDParamsPaymentConfiguration ) : base(customerUpdateByExternalIDParamsPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsPaymentConfiguration( IReadOnlyDictionary rawData @@ -601,6 +652,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -635,15 +701,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -761,6 +831,7 @@ public enum CustomerUpdateByExternalIDParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateByExternalIDParamsPaymentProviderConverter @@ -779,6 +850,8 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => + CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateByExternalIDParamsPaymentProvider)(-1), }; } @@ -798,6 +871,8 @@ JsonSerializerOptions options CustomerUpdateByExternalIDParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerUpdateByExternalIDParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerUpdateByExternalIDParamsPaymentProvider.Netsuite => "netsuite", + CustomerUpdateByExternalIDParamsPaymentProvider.NetsuiteAmpersand => + "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -918,7 +993,7 @@ public CustomerUpdateByExternalIDParamsTaxConfiguration(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -939,7 +1014,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -960,7 +1035,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -981,7 +1056,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1004,7 +1079,7 @@ public bool TryPickNumeral( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1027,7 +1102,7 @@ public bool TryPickAnrok( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1049,7 +1124,7 @@ public bool TryPickStripe( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1060,12 +1135,12 @@ public bool TryPickStripe( /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1110,7 +1185,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1121,12 +1196,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateByExternalIDParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1206,10 +1281,10 @@ public override void Validate() ); } - public virtual bool Equals(CustomerUpdateByExternalIDParamsTaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomerUpdateByExternalIDParamsTaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1217,7 +1292,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateByExternalIDParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateByExternalIDParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateByExternalIDParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateByExternalIDParamsTaxConfigurationConverter @@ -1252,12 +1344,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1274,12 +1364,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1296,12 +1384,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1319,12 +1405,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1342,12 +1426,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1365,12 +1447,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1452,10 +1532,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral( CustomerUpdateByExternalIDParamsTaxConfigurationNumeral customerUpdateByExternalIDParamsTaxConfigurationNumeral ) : base(customerUpdateByExternalIDParamsTaxConfigurationNumeral) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationNumeral( IReadOnlyDictionary rawData @@ -1559,10 +1642,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok( CustomerUpdateByExternalIDParamsTaxConfigurationAnrok customerUpdateByExternalIDParamsTaxConfigurationAnrok ) : base(customerUpdateByExternalIDParamsTaxConfigurationAnrok) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationAnrok( IReadOnlyDictionary rawData @@ -1666,10 +1752,13 @@ public CustomerUpdateByExternalIDParamsTaxConfigurationStripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateByExternalIDParamsTaxConfigurationStripe( CustomerUpdateByExternalIDParamsTaxConfigurationStripe customerUpdateByExternalIDParamsTaxConfigurationStripe ) : base(customerUpdateByExternalIDParamsTaxConfigurationStripe) { } +#pragma warning restore CS8618 public CustomerUpdateByExternalIDParamsTaxConfigurationStripe( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/CustomerUpdateParams.cs b/src/Orb/Models/Customers/CustomerUpdateParams.cs index 084533d42..8229c480a 100644 --- a/src/Orb/Models/Customers/CustomerUpdateParams.cs +++ b/src/Orb/Models/Customers/CustomerUpdateParams.cs @@ -15,10 +15,15 @@ namespace Orb.Models.Customers; /// /// This endpoint can be used to update the `payment_provider`, `payment_provider_id`, /// `name`, `email`, `email_delivery`, `tax_id`, `auto_collection`, `metadata`, `shipping_address`, -/// `billing_address`, and `additional_emails` of an existing customer. Other fields -/// on a customer are currently immutable. +/// `billing_address`, `additional_emails`, and `currency` of an existing customer. +/// `currency` can only be set if it has not already been set on the customer. Other +/// fields on a customer are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class CustomerUpdateParams : ParamsBase +public record class CustomerUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -104,7 +109,8 @@ public AddressInput? BillingAddress /// /// An ISO 4217 currency string used for the customer's invoices and balance. - /// If not set at creation time, will be set at subscription creation time. + /// This can only be set if the customer does not already have a currency configured. + /// If not set at creation or update time, it will be set at subscription creation time. /// public string? Currency { @@ -366,31 +372,32 @@ public CustomerUpdateParamsTaxConfiguration? TaxConfiguration /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public CustomerTaxID? TaxID { @@ -404,6 +411,8 @@ public CustomerTaxID? TaxID public CustomerUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) : base(customerUpdateParams) { @@ -411,6 +420,7 @@ public CustomerUpdateParams(CustomerUpdateParams customerUpdateParams) this._rawBodyData = new(customerUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public CustomerUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -428,27 +438,61 @@ IReadOnlyDictionary rawBodyData CustomerUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string customerID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.CustomerID = customerID; } #pragma warning restore CS8618 - /// + /// public static CustomerUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string customerID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + customerID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["CustomerID"] = JsonSerializer.SerializeToElement(this.CustomerID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(CustomerUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.CustomerID?.Equals(other.CustomerID) ?? other.CustomerID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override System::Uri Url(ClientOptions options) @@ -479,6 +523,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -530,10 +579,13 @@ public override void Validate() public CustomerUpdateParamsPaymentConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsPaymentConfiguration( CustomerUpdateParamsPaymentConfiguration customerUpdateParamsPaymentConfiguration ) : base(customerUpdateParamsPaymentConfiguration) { } +#pragma warning restore CS8618 public CustomerUpdateParamsPaymentConfiguration( IReadOnlyDictionary rawData @@ -594,6 +646,21 @@ public required ApiEnum< init { this._rawData.Set("provider_type", value); } } + /// + /// The ID of a shared payment token granted by an agent to use as the default + /// payment instrument for this customer. When set, auto-collection will use + /// this token instead of the customer's default payment method. + /// + public string? DefaultSharedPaymentToken + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_shared_payment_token"); + } + init { this._rawData.Set("default_shared_payment_token", value); } + } + /// /// List of Stripe payment method types to exclude for this customer. Excluded /// payment methods will not be available for the customer to select during payment, @@ -628,15 +695,19 @@ public IReadOnlyList? ExcludedPaymentMethodTypes public override void Validate() { this.ProviderType.Validate(); + _ = this.DefaultSharedPaymentToken; _ = this.ExcludedPaymentMethodTypes; } public CustomerUpdateParamsPaymentConfigurationPaymentProvider() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsPaymentConfigurationPaymentProvider( CustomerUpdateParamsPaymentConfigurationPaymentProvider customerUpdateParamsPaymentConfigurationPaymentProvider ) : base(customerUpdateParamsPaymentConfigurationPaymentProvider) { } +#pragma warning restore CS8618 public CustomerUpdateParamsPaymentConfigurationPaymentProvider( IReadOnlyDictionary rawData @@ -748,6 +819,7 @@ public enum CustomerUpdateParamsPaymentProvider StripeCharge, StripeInvoice, Netsuite, + NetsuiteAmpersand, } sealed class CustomerUpdateParamsPaymentProviderConverter @@ -766,6 +838,7 @@ JsonSerializerOptions options "stripe_charge" => CustomerUpdateParamsPaymentProvider.StripeCharge, "stripe_invoice" => CustomerUpdateParamsPaymentProvider.StripeInvoice, "netsuite" => CustomerUpdateParamsPaymentProvider.Netsuite, + "netsuite_ampersand" => CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand, _ => (CustomerUpdateParamsPaymentProvider)(-1), }; } @@ -785,6 +858,7 @@ JsonSerializerOptions options CustomerUpdateParamsPaymentProvider.StripeCharge => "stripe_charge", CustomerUpdateParamsPaymentProvider.StripeInvoice => "stripe_invoice", CustomerUpdateParamsPaymentProvider.Netsuite => "netsuite", + CustomerUpdateParamsPaymentProvider.NetsuiteAmpersand => "netsuite_ampersand", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -905,7 +979,7 @@ public CustomerUpdateParamsTaxConfiguration(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -926,7 +1000,7 @@ public bool TryPickNewAvalara([NotNullWhen(true)] out NewAvalaraTaxConfiguration /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -947,7 +1021,7 @@ public bool TryPickNewTaxJar([NotNullWhen(true)] out NewTaxJarConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -968,7 +1042,7 @@ public bool TryPickNewSphere([NotNullWhen(true)] out NewSphereConfiguration? val /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -991,7 +1065,7 @@ public bool TryPickNumeral( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1014,7 +1088,7 @@ public bool TryPickAnrok( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1036,7 +1110,7 @@ public bool TryPickStripe( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1047,12 +1121,12 @@ public bool TryPickStripe( /// /// /// instance.Switch( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1097,7 +1171,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1108,12 +1182,12 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewAvalaraTaxConfiguration value) => {...}, - /// (NewTaxJarConfiguration value) => {...}, - /// (NewSphereConfiguration value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, - /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} + /// (NewAvalaraTaxConfiguration value) => {...}, + /// (NewTaxJarConfiguration value) => {...}, + /// (NewSphereConfiguration value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationNumeral value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationAnrok value) => {...}, + /// (CustomerUpdateParamsTaxConfigurationStripe value) => {...} /// ); /// /// @@ -1193,10 +1267,10 @@ public override void Validate() ); } - public virtual bool Equals(CustomerUpdateParamsTaxConfiguration? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CustomerUpdateParamsTaxConfiguration? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1204,7 +1278,24 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewAvalaraTaxConfiguration _ => 0, + NewTaxJarConfiguration _ => 1, + NewSphereConfiguration _ => 2, + CustomerUpdateParamsTaxConfigurationNumeral _ => 3, + CustomerUpdateParamsTaxConfigurationAnrok _ => 4, + CustomerUpdateParamsTaxConfigurationStripe _ => 5, + _ => -1, + }; + } } sealed class CustomerUpdateParamsTaxConfigurationConverter @@ -1239,12 +1330,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1261,12 +1350,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1283,12 +1370,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1306,12 +1391,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1329,12 +1412,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1352,12 +1433,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1439,10 +1518,13 @@ public CustomerUpdateParamsTaxConfigurationNumeral() this.TaxProvider = JsonSerializer.SerializeToElement("numeral"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationNumeral( CustomerUpdateParamsTaxConfigurationNumeral customerUpdateParamsTaxConfigurationNumeral ) : base(customerUpdateParamsTaxConfigurationNumeral) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationNumeral( IReadOnlyDictionary rawData @@ -1544,10 +1626,13 @@ public CustomerUpdateParamsTaxConfigurationAnrok() this.TaxProvider = JsonSerializer.SerializeToElement("anrok"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationAnrok( CustomerUpdateParamsTaxConfigurationAnrok customerUpdateParamsTaxConfigurationAnrok ) : base(customerUpdateParamsTaxConfigurationAnrok) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationAnrok( IReadOnlyDictionary rawData @@ -1649,10 +1734,13 @@ public CustomerUpdateParamsTaxConfigurationStripe() this.TaxProvider = JsonSerializer.SerializeToElement("stripe"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CustomerUpdateParamsTaxConfigurationStripe( CustomerUpdateParamsTaxConfigurationStripe customerUpdateParamsTaxConfigurationStripe ) : base(customerUpdateParamsTaxConfigurationStripe) { } +#pragma warning restore CS8618 public CustomerUpdateParamsTaxConfigurationStripe( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs b/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs index cfc574684..45de781f1 100644 --- a/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs +++ b/src/Orb/Models/Customers/NewAccountingSyncConfiguration.cs @@ -56,10 +56,13 @@ public override void Validate() public NewAccountingSyncConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAccountingSyncConfiguration( NewAccountingSyncConfiguration newAccountingSyncConfiguration ) : base(newAccountingSyncConfiguration) { } +#pragma warning restore CS8618 public NewAccountingSyncConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs b/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs index 59428dc6c..525a58b26 100644 --- a/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs +++ b/src/Orb/Models/Customers/NewAvalaraTaxConfiguration.cs @@ -69,8 +69,11 @@ public override void Validate() public NewAvalaraTaxConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewAvalaraTaxConfiguration(NewAvalaraTaxConfiguration newAvalaraTaxConfiguration) : base(newAvalaraTaxConfiguration) { } +#pragma warning restore CS8618 public NewAvalaraTaxConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewReportingConfiguration.cs b/src/Orb/Models/Customers/NewReportingConfiguration.cs index 2396d1936..bd38dd6af 100644 --- a/src/Orb/Models/Customers/NewReportingConfiguration.cs +++ b/src/Orb/Models/Customers/NewReportingConfiguration.cs @@ -30,8 +30,11 @@ public override void Validate() public NewReportingConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewReportingConfiguration(NewReportingConfiguration newReportingConfiguration) : base(newReportingConfiguration) { } +#pragma warning restore CS8618 public NewReportingConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewSphereConfiguration.cs b/src/Orb/Models/Customers/NewSphereConfiguration.cs index 79acde7db..26ad1397e 100644 --- a/src/Orb/Models/Customers/NewSphereConfiguration.cs +++ b/src/Orb/Models/Customers/NewSphereConfiguration.cs @@ -58,8 +58,11 @@ public override void Validate() public NewSphereConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewSphereConfiguration(NewSphereConfiguration newSphereConfiguration) : base(newSphereConfiguration) { } +#pragma warning restore CS8618 public NewSphereConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Customers/NewTaxJarConfiguration.cs b/src/Orb/Models/Customers/NewTaxJarConfiguration.cs index a1300db26..e7af4c5af 100644 --- a/src/Orb/Models/Customers/NewTaxJarConfiguration.cs +++ b/src/Orb/Models/Customers/NewTaxJarConfiguration.cs @@ -58,8 +58,11 @@ public override void Validate() public NewTaxJarConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public NewTaxJarConfiguration(NewTaxJarConfiguration newTaxJarConfiguration) : base(newTaxJarConfiguration) { } +#pragma warning restore CS8618 public NewTaxJarConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceConfiguration.cs b/src/Orb/Models/DimensionalPriceConfiguration.cs index 4b77999b6..915e8b526 100644 --- a/src/Orb/Models/DimensionalPriceConfiguration.cs +++ b/src/Orb/Models/DimensionalPriceConfiguration.cs @@ -48,10 +48,13 @@ public override void Validate() public DimensionalPriceConfiguration() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceConfiguration( DimensionalPriceConfiguration dimensionalPriceConfiguration ) : base(dimensionalPriceConfiguration) { } +#pragma warning restore CS8618 public DimensionalPriceConfiguration(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs index e349bd7f9..73e3a7199 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroup.cs @@ -121,8 +121,11 @@ public override void Validate() public DimensionalPriceGroup() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroup(DimensionalPriceGroup dimensionalPriceGroup) : base(dimensionalPriceGroup) { } +#pragma warning restore CS8618 public DimensionalPriceGroup(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs index 727a7b7a3..b02c9d9ab 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupCreateParams.cs @@ -19,8 +19,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// of widgets used and we want to charge differently depending on the color of the /// widget. We can create a price group with a dimension "color" and two prices: one /// that charges \$10 per red widget and one that charges \$20 per blue widget. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupCreateParams : ParamsBase +public record class DimensionalPriceGroupCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -104,6 +108,8 @@ public string? ExternalDimensionalPriceGroupID public DimensionalPriceGroupCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupCreateParams( DimensionalPriceGroupCreateParams dimensionalPriceGroupCreateParams ) @@ -111,6 +117,7 @@ DimensionalPriceGroupCreateParams dimensionalPriceGroupCreateParams { this._rawBodyData = new(dimensionalPriceGroupCreateParams._rawBodyData); } +#pragma warning restore CS8618 public DimensionalPriceGroupCreateParams( IReadOnlyDictionary rawHeaderData, @@ -137,7 +144,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -151,6 +158,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/dimensional_price_groups") @@ -176,4 +211,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs index 29adb7e1d..a5380f092 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupDimensionalPriceGroups.cs @@ -54,10 +54,13 @@ public override void Validate() public DimensionalPriceGroupDimensionalPriceGroups() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupDimensionalPriceGroups( DimensionalPriceGroupDimensionalPriceGroups dimensionalPriceGroupDimensionalPriceGroups ) : base(dimensionalPriceGroupDimensionalPriceGroups) { } +#pragma warning restore CS8618 public DimensionalPriceGroupDimensionalPriceGroups( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs index cf31718c3..cbb065993 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -65,5 +66,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not DimensionalPriceGroupListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs index b0850dda4..e7ea86042 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// /// List dimensional price groups +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupListParams : ParamsBase +public record class DimensionalPriceGroupListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -50,10 +54,13 @@ public long? Limit public DimensionalPriceGroupListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupListParams( DimensionalPriceGroupListParams dimensionalPriceGroupListParams ) : base(dimensionalPriceGroupListParams) { } +#pragma warning restore CS8618 public DimensionalPriceGroupListParams( IReadOnlyDictionary rawHeaderData, @@ -76,7 +83,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -88,6 +95,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(DimensionalPriceGroupListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/dimensional_price_groups") @@ -104,4 +137,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs index 703425c82..b6ed95ccf 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupRetrieveParams.cs @@ -10,13 +10,19 @@ namespace Orb.Models.DimensionalPriceGroups; /// /// Fetch dimensional price group +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupRetrieveParams : ParamsBase +public record class DimensionalPriceGroupRetrieveParams : ParamsBase { public string? DimensionalPriceGroupID { get; init; } public DimensionalPriceGroupRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupRetrieveParams( DimensionalPriceGroupRetrieveParams dimensionalPriceGroupRetrieveParams ) @@ -24,6 +30,7 @@ DimensionalPriceGroupRetrieveParams dimensionalPriceGroupRetrieveParams { this.DimensionalPriceGroupID = dimensionalPriceGroupRetrieveParams.DimensionalPriceGroupID; } +#pragma warning restore CS8618 public DimensionalPriceGroupRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -38,24 +45,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] DimensionalPriceGroupRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string dimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.DimensionalPriceGroupID = dimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string dimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + dimensionalPriceGroupID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["DimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.DimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(DimensionalPriceGroupRetrieveParams? other) + { + if (other == null) + { + return false; + } + return ( + this.DimensionalPriceGroupID?.Equals(other.DimensionalPriceGroupID) + ?? other.DimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -77,4 +121,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs index 14f6f05e1..dbcc9d2ba 100644 --- a/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/DimensionalPriceGroupUpdateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.DimensionalPriceGroups; /// This endpoint can be used to update the `external_dimensional_price_group_id` /// and `metadata` of an existing dimensional price group. Other fields on a dimensional /// price group are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class DimensionalPriceGroupUpdateParams : ParamsBase +public record class DimensionalPriceGroupUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -67,6 +71,8 @@ public string? ExternalDimensionalPriceGroupID public DimensionalPriceGroupUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public DimensionalPriceGroupUpdateParams( DimensionalPriceGroupUpdateParams dimensionalPriceGroupUpdateParams ) @@ -76,6 +82,7 @@ DimensionalPriceGroupUpdateParams dimensionalPriceGroupUpdateParams this._rawBodyData = new(dimensionalPriceGroupUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public DimensionalPriceGroupUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -93,27 +100,66 @@ IReadOnlyDictionary rawBodyData DimensionalPriceGroupUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string dimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.DimensionalPriceGroupID = dimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static DimensionalPriceGroupUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string dimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + dimensionalPriceGroupID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["DimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.DimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(DimensionalPriceGroupUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.DimensionalPriceGroupID?.Equals(other.DimensionalPriceGroupID) + ?? other.DimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -144,4 +190,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs index abd46f11f..0aaaa8c01 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDRetrieveParams.cs @@ -10,13 +10,19 @@ namespace Orb.Models.DimensionalPriceGroups.ExternalDimensionalPriceGroupID; /// /// Fetch dimensional price group by external ID +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalDimensionalPriceGroupIDRetrieveParams : ParamsBase +public record class ExternalDimensionalPriceGroupIDRetrieveParams : ParamsBase { public string? ExternalDimensionalPriceGroupID { get; init; } public ExternalDimensionalPriceGroupIDRetrieveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalDimensionalPriceGroupIDRetrieveParams( ExternalDimensionalPriceGroupIDRetrieveParams externalDimensionalPriceGroupIDRetrieveParams ) @@ -25,6 +31,7 @@ ExternalDimensionalPriceGroupIDRetrieveParams externalDimensionalPriceGroupIDRet this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupIDRetrieveParams.ExternalDimensionalPriceGroupID; } +#pragma warning restore CS8618 public ExternalDimensionalPriceGroupIDRetrieveParams( IReadOnlyDictionary rawHeaderData, @@ -39,24 +46,61 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ExternalDimensionalPriceGroupIDRetrieveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string externalDimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static ExternalDimensionalPriceGroupIDRetrieveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string externalDimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalDimensionalPriceGroupID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.ExternalDimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ExternalDimensionalPriceGroupIDRetrieveParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalDimensionalPriceGroupID?.Equals(other.ExternalDimensionalPriceGroupID) + ?? other.ExternalDimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -81,4 +125,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs index ff325e1fd..1478b3658 100644 --- a/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs +++ b/src/Orb/Models/DimensionalPriceGroups/ExternalDimensionalPriceGroupID/ExternalDimensionalPriceGroupIDUpdateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.DimensionalPriceGroups.ExternalDimensionalPriceGroupID; /// This endpoint can be used to update the `external_dimensional_price_group_id` /// and `metadata` of an existing dimensional price group. Other fields on a dimensional /// price group are currently immutable. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ExternalDimensionalPriceGroupIDUpdateParams : ParamsBase +public record class ExternalDimensionalPriceGroupIDUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -67,6 +71,8 @@ public string? ExternalDimensionalPriceGroupIDValue public ExternalDimensionalPriceGroupIDUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalDimensionalPriceGroupIDUpdateParams( ExternalDimensionalPriceGroupIDUpdateParams externalDimensionalPriceGroupIDUpdateParams ) @@ -77,6 +83,7 @@ ExternalDimensionalPriceGroupIDUpdateParams externalDimensionalPriceGroupIDUpdat this._rawBodyData = new(externalDimensionalPriceGroupIDUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ExternalDimensionalPriceGroupIDUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -94,27 +101,66 @@ IReadOnlyDictionary rawBodyData ExternalDimensionalPriceGroupIDUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string externalDimensionalPriceGroupID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ExternalDimensionalPriceGroupID = externalDimensionalPriceGroupID; } #pragma warning restore CS8618 - /// + /// public static ExternalDimensionalPriceGroupIDUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string externalDimensionalPriceGroupID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + externalDimensionalPriceGroupID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalDimensionalPriceGroupID"] = JsonSerializer.SerializeToElement( + this.ExternalDimensionalPriceGroupID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ExternalDimensionalPriceGroupIDUpdateParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalDimensionalPriceGroupID?.Equals(other.ExternalDimensionalPriceGroupID) + ?? other.ExternalDimensionalPriceGroupID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -148,4 +194,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs index e35f39d34..11a0f60e1 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCloseParams.cs @@ -13,18 +13,25 @@ namespace Orb.Models.Events.Backfills; /// Orb will asynchronously reflect the updated usage in invoice amounts and usage /// graphs. Once all of the updates are complete, the backfill's status will transition /// to `reflected`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillCloseParams : ParamsBase +public record class BackfillCloseParams : ParamsBase { public string? BackfillID { get; init; } public BackfillCloseParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCloseParams(BackfillCloseParams backfillCloseParams) : base(backfillCloseParams) { this.BackfillID = backfillCloseParams.BackfillID; } +#pragma warning restore CS8618 public BackfillCloseParams( IReadOnlyDictionary rawHeaderData, @@ -39,24 +46,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillCloseParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillCloseParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(BackfillCloseParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -78,4 +117,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs index dc13dfed5..502669e9a 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCloseResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillCloseResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCloseResponse(BackfillCloseResponse backfillCloseResponse) : base(backfillCloseResponse) { } +#pragma warning restore CS8618 public BackfillCloseResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs index 599437f17..2aea9f90e 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateParams.cs @@ -14,8 +14,8 @@ namespace Orb.Models.Events.Backfills; /// are older than the ingestion grace period. Performing a backfill in Orb involves /// 3 steps: /// -/// 1. Create the backfill, specifying its parameters. 2. [Ingest](ingest) usage -/// events, referencing the backfill (query parameter `backfill_id`). 3. [Close](close-backfill) +/// 1. Create the backfill, specifying its parameters. 2. [Ingest](/api-reference/event/ingest-events) +/// usage events, referencing the backfill (query parameter `backfill_id`). 3. [Close](close-backfill) /// the backfill, propagating the update in past usage throughout Orb. /// /// Changes from a backfill are not reflected until the backfill is closed, @@ -45,8 +45,12 @@ namespace Orb.Models.Events.Backfills; /// /// You may not have multiple backfills in a pending or pending_revert state /// with overlapping timeframes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillCreateParams : ParamsBase +public record class BackfillCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -165,11 +169,14 @@ public bool? ReplaceExistingEvents public BackfillCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCreateParams(BackfillCreateParams backfillCreateParams) : base(backfillCreateParams) { this._rawBodyData = new(backfillCreateParams._rawBodyData); } +#pragma warning restore CS8618 public BackfillCreateParams( IReadOnlyDictionary rawHeaderData, @@ -196,7 +203,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static BackfillCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -210,6 +217,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/backfills") @@ -235,4 +270,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs index 8e39a8db8..36ffce44f 100644 --- a/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillCreateResponse.cs @@ -108,14 +108,12 @@ public required bool ReplaceExistingEvents /// /// The status of the backfill. /// - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } @@ -172,8 +170,11 @@ public override void Validate() public BackfillCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillCreateResponse(BackfillCreateResponse backfillCreateResponse) : base(backfillCreateResponse) { } +#pragma warning restore CS8618 public BackfillCreateResponse(IReadOnlyDictionary rawData) { @@ -208,7 +209,7 @@ IReadOnlyDictionary rawData /// /// The status of the backfill. /// -[JsonConverter(typeof(global::Orb.Models.Events.Backfills.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Pending, @@ -217,9 +218,9 @@ public enum Status Reverted, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Events.Backfills.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -227,28 +228,24 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "pending" => global::Orb.Models.Events.Backfills.Status.Pending, - "reflected" => global::Orb.Models.Events.Backfills.Status.Reflected, - "pending_revert" => global::Orb.Models.Events.Backfills.Status.PendingRevert, - "reverted" => global::Orb.Models.Events.Backfills.Status.Reverted, - _ => (global::Orb.Models.Events.Backfills.Status)(-1), + "pending" => Status.Pending, + "reflected" => Status.Reflected, + "pending_revert" => Status.PendingRevert, + "reverted" => Status.Reverted, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Events.Backfills.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Events.Backfills.Status.Pending => "pending", - global::Orb.Models.Events.Backfills.Status.Reflected => "reflected", - global::Orb.Models.Events.Backfills.Status.PendingRevert => "pending_revert", - global::Orb.Models.Events.Backfills.Status.Reverted => "reverted", + Status.Pending => "pending", + Status.Reflected => "reflected", + Status.PendingRevert => "pending_revert", + Status.Reverted => "reverted", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs index da16f794e..f05dba004 100644 --- a/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Events.Backfills; /// /// This endpoint is used to fetch a backfill given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillFetchParams : ParamsBase +public record class BackfillFetchParams : ParamsBase { public string? BackfillID { get; init; } public BackfillFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillFetchParams(BackfillFetchParams backfillFetchParams) : base(backfillFetchParams) { this.BackfillID = backfillFetchParams.BackfillID; } +#pragma warning restore CS8618 public BackfillFetchParams( IReadOnlyDictionary rawHeaderData, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(BackfillFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs b/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs index 8015f7326..9e22f8ed9 100644 --- a/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillFetchResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillFetchResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillFetchResponse(BackfillFetchResponse backfillFetchResponse) : base(backfillFetchResponse) { } +#pragma warning restore CS8618 public BackfillFetchResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillListPage.cs b/src/Orb/Models/Events/Backfills/BackfillListPage.cs index 484a2f953..a5ef4e97c 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListPage.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not BackfillListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs b/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs index a7fbc7f21..a54bd5ddb 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListPageResponse.cs @@ -51,8 +51,11 @@ public override void Validate() public BackfillListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListPageResponse(BackfillListPageResponse backfillListPageResponse) : base(backfillListPageResponse) { } +#pragma warning restore CS8618 public BackfillListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillListParams.cs b/src/Orb/Models/Events/Backfills/BackfillListParams.cs index bde773bd4..42ed34f64 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListParams.cs @@ -13,10 +13,13 @@ namespace Orb.Models.Events.Backfills; /// /// The list of backfills is ordered starting from the most recently created /// backfill. The response also includes [`pagination_metadata`](/api-reference/pagination), -/// which lets the caller retrieve the next page of results if they exist. More information -/// about pagination can be found in the [Pagination-metadata schema](pagination). +/// which lets the caller retrieve the next page of results if they exist. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillListParams : ParamsBase +public record class BackfillListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -55,8 +58,11 @@ public long? Limit public BackfillListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListParams(BackfillListParams backfillListParams) : base(backfillListParams) { } +#pragma warning restore CS8618 public BackfillListParams( IReadOnlyDictionary rawHeaderData, @@ -79,7 +85,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static BackfillListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -91,6 +97,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/backfills") @@ -107,4 +139,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillListResponse.cs b/src/Orb/Models/Events/Backfills/BackfillListResponse.cs index f5702c641..a90adbc90 100644 --- a/src/Orb/Models/Events/Backfills/BackfillListResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillListResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillListResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillListResponse(BackfillListResponse backfillListResponse) : base(backfillListResponse) { } +#pragma warning restore CS8618 public BackfillListResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs index 5aaaacb07..490e4387a 100644 --- a/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs +++ b/src/Orb/Models/Events/Backfills/BackfillRevertParams.cs @@ -16,18 +16,25 @@ namespace Orb.Models.Events.Backfills; /// /// If a backfill is reverted before its closed, no usage will be updated as /// a result of the backfill and it will immediately transition to `reverted`. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class BackfillRevertParams : ParamsBase +public record class BackfillRevertParams : ParamsBase { public string? BackfillID { get; init; } public BackfillRevertParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillRevertParams(BackfillRevertParams backfillRevertParams) : base(backfillRevertParams) { this.BackfillID = backfillRevertParams.BackfillID; } +#pragma warning restore CS8618 public BackfillRevertParams( IReadOnlyDictionary rawHeaderData, @@ -42,26 +49,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] BackfillRevertParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string backfillID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.BackfillID = backfillID; } #pragma warning restore CS8618 - /// + /// public static BackfillRevertParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string backfillID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + backfillID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["BackfillID"] = JsonSerializer.SerializeToElement(this.BackfillID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(BackfillRevertParams? other) + { + if (other == null) + { + return false; + } + return (this.BackfillID?.Equals(other.BackfillID) ?? other.BackfillID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -81,4 +120,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs b/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs index b427f82e9..b67f7298b 100644 --- a/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs +++ b/src/Orb/Models/Events/Backfills/BackfillRevertResponse.cs @@ -172,8 +172,11 @@ public override void Validate() public BackfillRevertResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BackfillRevertResponse(BackfillRevertResponse backfillRevertResponse) : base(backfillRevertResponse) { } +#pragma warning restore CS8618 public BackfillRevertResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventDeprecateParams.cs b/src/Orb/Models/Events/EventDeprecateParams.cs index 59cac2ffa..20f852c92 100644 --- a/src/Orb/Models/Events/EventDeprecateParams.cs +++ b/src/Orb/Models/Events/EventDeprecateParams.cs @@ -42,18 +42,25 @@ namespace Orb.Models.Events; /// events for customers not in the Orb system. * By default, no more than 100 events /// can be deprecated for a single customer in a 100 day period. For higher volume /// updates, consider using the [event backfill](create-backfill) endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventDeprecateParams : ParamsBase +public record class EventDeprecateParams : ParamsBase { public string? EventID { get; init; } public EventDeprecateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventDeprecateParams(EventDeprecateParams eventDeprecateParams) : base(eventDeprecateParams) { this.EventID = eventDeprecateParams.EventID; } +#pragma warning restore CS8618 public EventDeprecateParams( IReadOnlyDictionary rawHeaderData, @@ -68,26 +75,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] EventDeprecateParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string eventID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.EventID = eventID; } #pragma warning restore CS8618 - /// + /// public static EventDeprecateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string eventID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + eventID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["EventID"] = JsonSerializer.SerializeToElement(this.EventID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventDeprecateParams? other) + { + if (other == null) + { + return false; + } + return (this.EventID?.Equals(other.EventID) ?? other.EventID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -107,4 +146,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventDeprecateResponse.cs b/src/Orb/Models/Events/EventDeprecateResponse.cs index 22151fd23..0a5793a09 100644 --- a/src/Orb/Models/Events/EventDeprecateResponse.cs +++ b/src/Orb/Models/Events/EventDeprecateResponse.cs @@ -31,8 +31,11 @@ public override void Validate() public EventDeprecateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventDeprecateResponse(EventDeprecateResponse eventDeprecateResponse) : base(eventDeprecateResponse) { } +#pragma warning restore CS8618 public EventDeprecateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventIngestParams.cs b/src/Orb/Models/Events/EventIngestParams.cs index dc9ebda8b..e873a737b 100644 --- a/src/Orb/Models/Events/EventIngestParams.cs +++ b/src/Orb/Models/Events/EventIngestParams.cs @@ -62,7 +62,7 @@ namespace Orb.Models.Events; /// collide). - The `timestamp` field in the event body will be used to determine /// which billable period a given event falls into. For example, with a monthly billing /// cycle starting from the first of December, Orb will calculate metrics based on -/// events that fall into the range `12-01 00:00:00 <= timestamp < 01-01 00:00:00`. +/// events that fall into the range `12-01 00:00:00 <= timestamp < 01-01 00:00:00`. /// /// ## Logging metadata /// @@ -97,10 +97,10 @@ namespace Orb.Models.Events; /// /// In cases where usage is reported in aggregate for a historical timeframe, /// the timestamp must be within the grace period set for your account. Events with -/// `timestamp < current_time - grace_period` will not be accepted as a valid event, -/// and will throw validation errors. Enforcing the grace period enables Orb to accurately -/// map usage to the correct billing cycle and ensure that all usage is billed for -/// in the corresponding billing period. +/// `timestamp < current_time - grace_period` will not be accepted as a valid +/// event, and will throw validation errors. Enforcing the grace period enables Orb +/// to accurately map usage to the correct billing cycle and ensure that all usage +/// is billed for in the corresponding billing period. /// /// In general, Orb does not expect events with future dated timestamps. In /// cases where the timestamp is at least 24 hours ahead of the current time, the @@ -175,8 +175,12 @@ namespace Orb.Models.Events; /// #### Example: ingestion response with `debug=false` /// /// ```json { "validation_failed": [] } ``` +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventIngestParams : ParamsBase +public record class EventIngestParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -237,11 +241,14 @@ public bool? Debug public EventIngestParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventIngestParams(EventIngestParams eventIngestParams) : base(eventIngestParams) { this._rawBodyData = new(eventIngestParams._rawBodyData); } +#pragma warning restore CS8618 public EventIngestParams( IReadOnlyDictionary rawHeaderData, @@ -268,7 +275,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static EventIngestParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -282,6 +289,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventIngestParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/ingest") @@ -307,6 +342,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -416,8 +456,11 @@ public override void Validate() public Event() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Event(Event event_) : base(event_) { } +#pragma warning restore CS8618 public Event(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventIngestResponse.cs b/src/Orb/Models/Events/EventIngestResponse.cs index 88e52d753..f360128ea 100644 --- a/src/Orb/Models/Events/EventIngestResponse.cs +++ b/src/Orb/Models/Events/EventIngestResponse.cs @@ -59,8 +59,11 @@ public override void Validate() public EventIngestResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventIngestResponse(EventIngestResponse eventIngestResponse) : base(eventIngestResponse) { } +#pragma warning restore CS8618 public EventIngestResponse(IReadOnlyDictionary rawData) { @@ -142,8 +145,11 @@ public override void Validate() public ValidationFailed() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ValidationFailed(ValidationFailed validationFailed) : base(validationFailed) { } +#pragma warning restore CS8618 public ValidationFailed(IReadOnlyDictionary rawData) { @@ -222,8 +228,11 @@ public override void Validate() public Debug() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Debug(Debug debug) : base(debug) { } +#pragma warning restore CS8618 public Debug(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventSearchParams.cs b/src/Orb/Models/Events/EventSearchParams.cs index 9dc0f9842..d79f47f4f 100644 --- a/src/Orb/Models/Events/EventSearchParams.cs +++ b/src/Orb/Models/Events/EventSearchParams.cs @@ -25,8 +25,12 @@ namespace Orb.Models.Events; /// /// By default, Orb will not throw a `404` if no events matched, Orb will return /// an empty array for `data` instead. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventSearchParams : ParamsBase +public record class EventSearchParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -86,11 +90,14 @@ public DateTimeOffset? TimeframeStart public EventSearchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventSearchParams(EventSearchParams eventSearchParams) : base(eventSearchParams) { this._rawBodyData = new(eventSearchParams._rawBodyData); } +#pragma warning restore CS8618 public EventSearchParams( IReadOnlyDictionary rawHeaderData, @@ -117,7 +124,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static EventSearchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -131,6 +138,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventSearchParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/search") @@ -156,4 +191,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventSearchResponse.cs b/src/Orb/Models/Events/EventSearchResponse.cs index d72519af7..2f1419d72 100644 --- a/src/Orb/Models/Events/EventSearchResponse.cs +++ b/src/Orb/Models/Events/EventSearchResponse.cs @@ -36,8 +36,11 @@ public override void Validate() public EventSearchResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventSearchResponse(EventSearchResponse eventSearchResponse) : base(eventSearchResponse) { } +#pragma warning restore CS8618 public EventSearchResponse(IReadOnlyDictionary rawData) { @@ -201,8 +204,11 @@ public override void Validate() public Data() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/EventUpdateParams.cs b/src/Orb/Models/Events/EventUpdateParams.cs index 05eb52a75..6096c9e65 100644 --- a/src/Orb/Models/Events/EventUpdateParams.cs +++ b/src/Orb/Models/Events/EventUpdateParams.cs @@ -48,8 +48,12 @@ namespace Orb.Models.Events; /// previous billing period. * By default, no more than 100 events can be amended /// for a single customer in a 100 day period. For higher volume updates, consider /// using the [event backfill](create-backfill) endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class EventUpdateParams : ParamsBase +public record class EventUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -137,6 +141,8 @@ public string? ExternalCustomerID public EventUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventUpdateParams(EventUpdateParams eventUpdateParams) : base(eventUpdateParams) { @@ -144,6 +150,7 @@ public EventUpdateParams(EventUpdateParams eventUpdateParams) this._rawBodyData = new(eventUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public EventUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -161,29 +168,63 @@ IReadOnlyDictionary rawBodyData EventUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string eventID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.EventID = eventID; } #pragma warning restore CS8618 - /// + /// public static EventUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string eventID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + eventID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["EventID"] = JsonSerializer.SerializeToElement(this.EventID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(EventUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.EventID?.Equals(other.EventID) ?? other.EventID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -211,4 +252,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Events/EventUpdateResponse.cs b/src/Orb/Models/Events/EventUpdateResponse.cs index 4005fedf2..15fd3f0bc 100644 --- a/src/Orb/Models/Events/EventUpdateResponse.cs +++ b/src/Orb/Models/Events/EventUpdateResponse.cs @@ -31,8 +31,11 @@ public override void Validate() public EventUpdateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventUpdateResponse(EventUpdateResponse eventUpdateResponse) : base(eventUpdateResponse) { } +#pragma warning restore CS8618 public EventUpdateResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Events/Volume/EventVolumes.cs b/src/Orb/Models/Events/Volume/EventVolumes.cs index 617b5f4dc..cea58a513 100644 --- a/src/Orb/Models/Events/Volume/EventVolumes.cs +++ b/src/Orb/Models/Events/Volume/EventVolumes.cs @@ -12,21 +12,16 @@ namespace Orb.Models.Events.Volume; [JsonConverter(typeof(JsonModelConverter))] public sealed record class EventVolumes : JsonModel { - public required IReadOnlyList Data + public required IReadOnlyList Data { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("data"); + return this._rawData.GetNotNullStruct>("data"); } init { - this._rawData.Set>( - "data", - ImmutableArray.ToImmutableArray(value) - ); + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); } } @@ -41,8 +36,11 @@ public override void Validate() public EventVolumes() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public EventVolumes(EventVolumes eventVolumes) : base(eventVolumes) { } +#pragma warning restore CS8618 public EventVolumes(IReadOnlyDictionary rawData) { @@ -64,7 +62,7 @@ public static EventVolumes FromRawUnchecked(IReadOnlyDictionary data) + public EventVolumes(IReadOnlyList data) : this() { this.Data = data; @@ -82,12 +80,7 @@ public EventVolumes FromRawUnchecked(IReadOnlyDictionary ra /// An EventVolume contains the event volume ingested in an hourly window. The timestamp /// used for the aggregation is the `timestamp` datetime field on events. /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Events.Volume.Data, - global::Orb.Models.Events.Volume.DataFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Data : JsonModel { /// @@ -133,8 +126,11 @@ public override void Validate() public Data() { } - public Data(global::Orb.Models.Events.Volume.Data data) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) : base(data) { } +#pragma warning restore CS8618 public Data(IReadOnlyDictionary rawData) { @@ -149,19 +145,16 @@ public Data(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class DataFromRaw : IFromRawJson +class DataFromRaw : IFromRawJson { /// - public global::Orb.Models.Events.Volume.Data FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Events.Volume.Data.FromRawUnchecked(rawData); + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); } diff --git a/src/Orb/Models/Events/Volume/VolumeListParams.cs b/src/Orb/Models/Events/Volume/VolumeListParams.cs index eec55f973..6338349a3 100644 --- a/src/Orb/Models/Events/Volume/VolumeListParams.cs +++ b/src/Orb/Models/Events/Volume/VolumeListParams.cs @@ -20,8 +20,12 @@ namespace Orb.Models.Events.Volume; /// hour where the start and end time are hour-aligned and in UTC. When a specific /// timestamp is passed in for either start or end time, the response includes the /// hours the timestamp falls in. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class VolumeListParams : ParamsBase +public record class VolumeListParams : ParamsBase { /// /// The start of the timeframe, inclusive, in which to return event volume. All @@ -99,8 +103,11 @@ public DateTimeOffset? TimeframeEnd public VolumeListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public VolumeListParams(VolumeListParams volumeListParams) : base(volumeListParams) { } +#pragma warning restore CS8618 public VolumeListParams( IReadOnlyDictionary rawHeaderData, @@ -123,7 +130,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static VolumeListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -135,6 +142,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(VolumeListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/events/volume") @@ -151,4 +184,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs b/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs index c6a6f8b05..d38069da1 100644 --- a/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs +++ b/src/Orb/Models/FixedFeeQuantityScheduleEntry.cs @@ -64,10 +64,13 @@ public override void Validate() public FixedFeeQuantityScheduleEntry() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public FixedFeeQuantityScheduleEntry( FixedFeeQuantityScheduleEntry fixedFeeQuantityScheduleEntry ) : base(fixedFeeQuantityScheduleEntry) { } +#pragma warning restore CS8618 public FixedFeeQuantityScheduleEntry(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/FixedFeeQuantityTransition.cs b/src/Orb/Models/FixedFeeQuantityTransition.cs index d964ab0ce..d3760050e 100644 --- a/src/Orb/Models/FixedFeeQuantityTransition.cs +++ b/src/Orb/Models/FixedFeeQuantityTransition.cs @@ -53,8 +53,11 @@ public override void Validate() public FixedFeeQuantityTransition() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoice.cs b/src/Orb/Models/Invoice.cs index 55e12542c..ba904a797 100644 --- a/src/Orb/Models/Invoice.cs +++ b/src/Orb/Models/Invoice.cs @@ -218,31 +218,32 @@ public required IReadOnlyList CustomerBalance /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public required CustomerTaxID? CustomerTaxID { @@ -747,9 +748,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public Invoice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public Invoice(Invoice invoice) : base(invoice) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public Invoice(IReadOnlyDictionary rawData) @@ -855,8 +859,11 @@ public override void Validate() public InvoiceAutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceAutoCollection(InvoiceAutoCollection invoiceAutoCollection) : base(invoiceAutoCollection) { } +#pragma warning restore CS8618 public InvoiceAutoCollection(IReadOnlyDictionary rawData) { @@ -982,8 +989,11 @@ public override void Validate() public InvoiceCreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCreditNote(InvoiceCreditNote invoiceCreditNote) : base(invoiceCreditNote) { } +#pragma warning restore CS8618 public InvoiceCreditNote(IReadOnlyDictionary rawData) { @@ -1162,10 +1172,13 @@ public override void Validate() public InvoiceCustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCustomerBalanceTransaction( InvoiceCustomerBalanceTransaction invoiceCustomerBalanceTransaction ) : base(invoiceCustomerBalanceTransaction) { } +#pragma warning restore CS8618 public InvoiceCustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1394,8 +1407,8 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// public required IReadOnlyList Adjustments { @@ -1663,8 +1676,11 @@ public override void Validate() public InvoiceLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItem(InvoiceLineItem invoiceLineItem) : base(invoiceLineItem) { } +#pragma warning restore CS8618 public InvoiceLineItem(IReadOnlyDictionary rawData) { @@ -1829,7 +1845,7 @@ public InvoiceLineItemAdjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1852,7 +1868,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1875,7 +1891,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1898,7 +1914,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1919,7 +1935,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1939,7 +1955,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1950,11 +1966,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -1995,7 +2011,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2006,11 +2022,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2081,10 +2097,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLineItemAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLineItemAdjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2092,7 +2108,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } sealed class InvoiceLineItemAdjustmentConverter : JsonConverter @@ -2126,12 +2158,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2148,12 +2178,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2171,12 +2199,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2193,12 +2219,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2215,12 +2239,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2326,7 +2348,7 @@ public InvoiceLineItemSubLineItem(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2347,7 +2369,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2368,7 +2390,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2388,7 +2410,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2399,9 +2421,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2434,7 +2456,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2445,9 +2467,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2502,10 +2524,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLineItemSubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLineItemSubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2513,7 +2535,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } sealed class InvoiceLineItemSubLineItemConverter : JsonConverter @@ -2547,12 +2583,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2569,12 +2603,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2591,12 +2623,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2731,8 +2761,11 @@ public override void Validate() public InvoicePaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoicePaymentAttempt(InvoicePaymentAttempt invoicePaymentAttempt) : base(invoicePaymentAttempt) { } +#pragma warning restore CS8618 public InvoicePaymentAttempt(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/InvoiceLevelDiscount.cs b/src/Orb/Models/InvoiceLevelDiscount.cs index 33a9f2f42..dbc4afc0e 100644 --- a/src/Orb/Models/InvoiceLevelDiscount.cs +++ b/src/Orb/Models/InvoiceLevelDiscount.cs @@ -64,7 +64,7 @@ public InvoiceLevelDiscount(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -85,7 +85,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out PercentageDiscount? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -106,7 +106,7 @@ public bool TryPickAmount([NotNullWhen(true)] out AmountDiscount? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -126,7 +126,7 @@ public bool TryPickTrial([NotNullWhen(true)] out TrialDiscount? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -137,9 +137,9 @@ public bool TryPickTrial([NotNullWhen(true)] out TrialDiscount? value) /// /// /// instance.Switch( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...}, - /// (TrialDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...}, + /// (TrialDiscount value) => {...} /// ); /// /// @@ -172,7 +172,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -183,9 +183,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (PercentageDiscount value) => {...}, - /// (AmountDiscount value) => {...}, - /// (TrialDiscount value) => {...} + /// (PercentageDiscount value) => {...}, + /// (AmountDiscount value) => {...}, + /// (TrialDiscount value) => {...} /// ); /// /// @@ -238,10 +238,10 @@ public override void Validate() ); } - public virtual bool Equals(InvoiceLevelDiscount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceLevelDiscount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -249,7 +249,21 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + PercentageDiscount _ => 0, + AmountDiscount _ => 1, + TrialDiscount _ => 2, + _ => -1, + }; + } } sealed class InvoiceLevelDiscountConverter : JsonConverter @@ -283,12 +297,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -302,12 +314,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -321,12 +331,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs index 2604e2c94..9be798411 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateParams.cs @@ -21,8 +21,12 @@ namespace Orb.Models.InvoiceLineItems; /// for the line item. - If both `item_id` and `name` are provided: The item is looked /// up by ID for association, but the provided `name` is used for the line item /// (not the item's name). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceLineItemCreateParams : ParamsBase +public record class InvoiceLineItemCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -131,11 +135,14 @@ public string? Name public InvoiceLineItemCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItemCreateParams(InvoiceLineItemCreateParams invoiceLineItemCreateParams) : base(invoiceLineItemCreateParams) { this._rawBodyData = new(invoiceLineItemCreateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceLineItemCreateParams( IReadOnlyDictionary rawHeaderData, @@ -162,7 +169,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static InvoiceLineItemCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -176,6 +183,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceLineItemCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoice_line_items") @@ -201,4 +236,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs index 8e2e54507..77459b3b2 100644 --- a/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs +++ b/src/Orb/Models/InvoiceLineItems/InvoiceLineItemCreateResponse.cs @@ -44,21 +44,19 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// - public required IReadOnlyList Adjustments + public required IReadOnlyList Adjustments { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("adjustments"); + return this._rawData.GetNotNullStruct>("adjustments"); } init { - this._rawData.Set>( + this._rawData.Set>( "adjustments", ImmutableArray.ToImmutableArray(value) ); @@ -210,18 +208,16 @@ public required double Quantity /// For complex pricing structures, the line item can be broken down further /// in `sub_line_items`. /// - public required IReadOnlyList SubLineItems + public required IReadOnlyList SubLineItems { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("sub_line_items"); + return this._rawData.GetNotNullStruct>("sub_line_items"); } init { - this._rawData.Set>( + this._rawData.Set>( "sub_line_items", ImmutableArray.ToImmutableArray(value) ); @@ -313,10 +309,13 @@ public override void Validate() public InvoiceLineItemCreateResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceLineItemCreateResponse( InvoiceLineItemCreateResponse invoiceLineItemCreateResponse ) : base(invoiceLineItemCreateResponse) { } +#pragma warning restore CS8618 public InvoiceLineItemCreateResponse(IReadOnlyDictionary rawData) { @@ -348,7 +347,7 @@ IReadOnlyDictionary rawData ) => InvoiceLineItemCreateResponse.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.InvoiceLineItems.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -475,7 +474,7 @@ public Adjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -498,7 +497,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -521,7 +520,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -544,7 +543,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -565,7 +564,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -585,7 +584,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -596,11 +595,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -639,7 +638,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -650,11 +649,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -678,25 +677,17 @@ public T Match( }; } - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryUsageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryUsageDiscountAdjustment value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryAmountDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryAmountDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryPercentageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryPercentageDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryMinimumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMinimumAdjustment value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.Adjustment( - MonetaryMaximumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMaximumAdjustment value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -723,10 +714,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -734,12 +725,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.InvoiceLineItems.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -768,12 +775,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -790,12 +795,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -813,12 +816,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -835,12 +836,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -857,12 +856,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -871,14 +868,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.InvoiceLineItems.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.InvoiceLineItems.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -886,7 +883,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.InvoiceLineItems.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -968,7 +965,7 @@ public SubLineItem(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -989,7 +986,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1010,7 +1007,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1030,7 +1027,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1041,9 +1038,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -1074,7 +1071,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1085,9 +1082,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -1107,17 +1104,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - MatrixSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(MatrixSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - TierSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(TierSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.InvoiceLineItems.SubLineItem( - OtherSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(OtherSubLineItem value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1142,10 +1133,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.InvoiceLineItems.SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1153,12 +1144,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } -sealed class SubLineItemConverter : JsonConverter +sealed class SubLineItemConverter : JsonConverter { - public override global::Orb.Models.InvoiceLineItems.SubLineItem? Read( + public override SubLineItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1187,12 +1192,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1209,12 +1212,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1231,12 +1232,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1245,14 +1244,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.InvoiceLineItems.SubLineItem(element); + return new SubLineItem(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.InvoiceLineItems.SubLineItem value, + SubLineItem value, JsonSerializerOptions options ) { diff --git a/src/Orb/Models/InvoiceTiny.cs b/src/Orb/Models/InvoiceTiny.cs index ed3bf0a69..2f2c38ff0 100644 --- a/src/Orb/Models/InvoiceTiny.cs +++ b/src/Orb/Models/InvoiceTiny.cs @@ -31,8 +31,11 @@ public override void Validate() public InvoiceTiny() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceTiny(InvoiceTiny invoiceTiny) : base(invoiceTiny) { } +#pragma warning restore CS8618 public InvoiceTiny(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceCreateParams.cs b/src/Orb/Models/Invoices/InvoiceCreateParams.cs index c572f34f6..a0172b0b2 100644 --- a/src/Orb/Models/Invoices/InvoiceCreateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceCreateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint is used to create a one-off invoice for a customer. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceCreateParams : ParamsBase +public record class InvoiceCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -51,24 +55,37 @@ public required string Currency init { this._rawBodyData.Set("invoice_date", value); } } - public required IReadOnlyList LineItems + public required IReadOnlyList LineItems { get { this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullStruct< - ImmutableArray - >("line_items"); + return this._rawBodyData.GetNotNullStruct>("line_items"); } init { - this._rawBodyData.Set>( + this._rawBodyData.Set>( "line_items", ImmutableArray.ToImmutableArray(value) ); } } + /// + /// Determines whether this invoice will automatically attempt to charge a saved + /// payment method, if any. If not specified, the invoice inherits the customer's + /// auto_collection setting. + /// + public bool? AutoCollection + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("auto_collection"); + } + init { this._rawBodyData.Set("auto_collection", value); } + } + /// /// The id of the `Customer` to create this invoice for. One of `customer_id` /// and `external_customer_id` are required. @@ -204,11 +221,14 @@ public bool? WillAutoIssue public InvoiceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceCreateParams(InvoiceCreateParams invoiceCreateParams) : base(invoiceCreateParams) { this._rawBodyData = new(invoiceCreateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceCreateParams( IReadOnlyDictionary rawHeaderData, @@ -235,7 +255,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static InvoiceCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -249,6 +269,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices") @@ -274,14 +322,14 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.LineItem, - global::Orb.Models.Invoices.LineItemFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class LineItem : JsonModel { /// @@ -307,14 +355,12 @@ public required string ItemID init { this._rawData.Set("item_id", value); } } - public required ApiEnum ModelType + public required ApiEnum ModelType { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("model_type"); + return this._rawData.GetNotNullClass>("model_type"); } init { this._rawData.Set("model_type", value); } } @@ -385,8 +431,11 @@ public override void Validate() public LineItem() { } - public LineItem(global::Orb.Models.Invoices.LineItem lineItem) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LineItem(LineItem lineItem) : base(lineItem) { } +#pragma warning restore CS8618 public LineItem(IReadOnlyDictionary rawData) { @@ -401,32 +450,29 @@ public LineItem(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static LineItem FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class LineItemFromRaw : IFromRawJson +class LineItemFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.LineItem FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.LineItem.FromRawUnchecked(rawData); + public LineItem FromRawUnchecked(IReadOnlyDictionary rawData) => + LineItem.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.ModelTypeConverter))] +[JsonConverter(typeof(ModelTypeConverter))] public enum ModelType { Unit, } -sealed class ModelTypeConverter : JsonConverter +sealed class ModelTypeConverter : JsonConverter { - public override global::Orb.Models.Invoices.ModelType Read( + public override ModelType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -434,14 +480,14 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "unit" => global::Orb.Models.Invoices.ModelType.Unit, - _ => (global::Orb.Models.Invoices.ModelType)(-1), + "unit" => ModelType.Unit, + _ => (ModelType)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.ModelType value, + ModelType value, JsonSerializerOptions options ) { @@ -449,7 +495,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.ModelType.Unit => "unit", + ModelType.Unit => "unit", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -502,7 +548,7 @@ public DueDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -523,7 +569,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -543,7 +589,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -554,8 +600,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -582,7 +628,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -593,8 +639,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -634,10 +680,10 @@ public override void Validate() } } - public virtual bool Equals(DueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -645,7 +691,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class DueDateConverter : JsonConverter @@ -672,7 +731,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs index 526c14b14..aa866c7da 100644 --- a/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs +++ b/src/Orb/Models/Invoices/InvoiceDeleteLineItemParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint only allows deletion of one-off line items (not subscription-based /// line items). The invoice must be in a draft status for this operation to succeed. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceDeleteLineItemParams : ParamsBase +public record class InvoiceDeleteLineItemParams : ParamsBase { public required string InvoiceID { get; init; } @@ -22,12 +26,15 @@ public sealed record class InvoiceDeleteLineItemParams : ParamsBase public InvoiceDeleteLineItemParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceDeleteLineItemParams(InvoiceDeleteLineItemParams invoiceDeleteLineItemParams) : base(invoiceDeleteLineItemParams) { this.InvoiceID = invoiceDeleteLineItemParams.InvoiceID; this.LineItemID = invoiceDeleteLineItemParams.LineItemID; } +#pragma warning restore CS8618 public InvoiceDeleteLineItemParams( IReadOnlyDictionary rawHeaderData, @@ -42,26 +49,64 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceDeleteLineItemParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID, + string lineItemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; + this.LineItemID = lineItemID; } #pragma warning restore CS8618 - /// + /// public static InvoiceDeleteLineItemParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID, + string lineItemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID, + lineItemID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["LineItemID"] = JsonSerializer.SerializeToElement(this.LineItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceDeleteLineItemParams? other) + { + if (other == null) + { + return false; + } + return this.InvoiceID.Equals(other.InvoiceID) + && (this.LineItemID?.Equals(other.LineItemID) ?? other.LineItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +130,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchParams.cs b/src/Orb/Models/Invoices/InvoiceFetchParams.cs index 563df22da..a0007db76 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Invoices; /// /// This endpoint is used to fetch an [`Invoice`](/core-concepts#invoice) given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceFetchParams : ParamsBase +public record class InvoiceFetchParams : ParamsBase { public string? InvoiceID { get; init; } public InvoiceFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchParams(InvoiceFetchParams invoiceFetchParams) : base(invoiceFetchParams) { this.InvoiceID = invoiceFetchParams.InvoiceID; } +#pragma warning restore CS8618 public InvoiceFetchParams( IReadOnlyDictionary rawHeaderData, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(InvoiceFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -74,4 +113,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs index 193ec1bf6..18ea5fc57 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint can be used to fetch the upcoming [invoice](/core-concepts#invoice) /// for the current billing period given a subscription. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceFetchUpcomingParams : ParamsBase +public record class InvoiceFetchUpcomingParams : ParamsBase { public required string SubscriptionID { @@ -26,8 +30,11 @@ public required string SubscriptionID public InvoiceFetchUpcomingParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchUpcomingParams(InvoiceFetchUpcomingParams invoiceFetchUpcomingParams) : base(invoiceFetchUpcomingParams) { } +#pragma warning restore CS8618 public InvoiceFetchUpcomingParams( IReadOnlyDictionary rawHeaderData, @@ -50,7 +57,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static InvoiceFetchUpcomingParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -62,6 +69,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceFetchUpcomingParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/invoices/upcoming") @@ -78,4 +111,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs index 01a532f8c..c0e1f588f 100644 --- a/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceFetchUpcomingResponse.cs @@ -39,14 +39,12 @@ public required string AmountDue init { this._rawData.Set("amount_due", value); } } - public required global::Orb.Models.Invoices.AutoCollection AutoCollection + public required AutoCollection AutoCollection { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "auto_collection" - ); + return this._rawData.GetNotNullClass("auto_collection"); } init { this._rawData.Set("auto_collection", value); } } @@ -77,18 +75,16 @@ public required Address? BillingAddress /// /// A list of credit notes associated with the invoice /// - public required IReadOnlyList CreditNotes + public required IReadOnlyList CreditNotes { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("credit_notes"); + return this._rawData.GetNotNullStruct>("credit_notes"); } init { - this._rawData.Set>( + this._rawData.Set>( "credit_notes", ImmutableArray.ToImmutableArray(value) ); @@ -118,20 +114,21 @@ public required CustomerMinified Customer init { this._rawData.Set("customer", value); } } - public required IReadOnlyList CustomerBalanceTransactions + public required IReadOnlyList CustomerBalanceTransactions { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("customer_balance_transactions"); + return this._rawData.GetNotNullStruct>( + "customer_balance_transactions" + ); } init { - this._rawData.Set< - ImmutableArray - >("customer_balance_transactions", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "customer_balance_transactions", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -214,31 +211,32 @@ public required CustomerMinified Customer /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number - /// | | Poland | `eu_vat` | European VAT Number | | Portugal | `eu_vat` | European - /// VAT Number | | Romania | `eu_vat` | European VAT Number | | Romania | `ro_tin` - /// | Romanian Tax ID Number | | Russia | `ru_inn` | Russian INN | | Russia | - /// `ru_kpp` | Russian KPP | | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | - /// Senegal | `sn_ninea` | Senegal NINEA Number | | Serbia | `rs_pib` | Serbian - /// PIB Number | | Singapore | `sg_gst` | Singaporean GST | | Singapore | `sg_uen` - /// | Singaporean UEN | | Slovakia | `eu_vat` | European VAT Number | | Slovenia - /// | `eu_vat` | European VAT Number | | Slovenia | `si_tin` | Slovenia Tax Number - /// (davčna številka) | | South Africa | `za_vat` | South African VAT Number | - /// | South Korea | `kr_brn` | Korean BRN | | Spain | `es_cif` | Spanish NIF - /// Number (previously Spanish CIF Number) | | Spain | `eu_vat` | European VAT - /// Number | | Suriname | `sr_fin` | Suriname FIN Number | | Sweden | `eu_vat` - /// | European VAT Number | | Switzerland | `ch_uid` | Switzerland UID Number - /// | | Switzerland | `ch_vat` | Switzerland VAT Number | | Taiwan | `tw_vat` - /// | Taiwanese VAT | | Tajikistan | `tj_tin` | Tajikistan Tax Identification - /// Number | | Tanzania | `tz_vat` | Tanzania VAT Number | | Thailand | `th_vat` - /// | Thai VAT | | Turkey | `tr_tin` | Turkish Tax Identification Number | | Uganda - /// | `ug_tin` | Uganda Tax Identification Number | | Ukraine | `ua_vat` | Ukrainian - /// VAT | | United Arab Emirates | `ae_trn` | United Arab Emirates TRN | | United - /// Kingdom | `gb_vat` | United Kingdom VAT Number | | United States | `us_ein` - /// | United States EIN | | Uruguay | `uy_ruc` | Uruguayan RUC Number | | Uzbekistan - /// | `uz_tin` | Uzbekistan TIN Number | | Uzbekistan | `uz_vat` | Uzbekistan - /// VAT Number | | Venezuela | `ve_rif` | Venezuelan RIF Number | | Vietnam | - /// `vn_tin` | Vietnamese Tax ID Number | | Zambia | `zm_tin` | Zambia Tax Identification - /// Number | | Zimbabwe | `zw_tin` | Zimbabwe Tax Identification Number | + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | /// public required CustomerTaxID? CustomerTaxID { @@ -355,14 +353,12 @@ public required string? InvoicePdf init { this._rawData.Set("invoice_pdf", value); } } - public required ApiEnum InvoiceSource + public required ApiEnum InvoiceSource { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("invoice_source"); + return this._rawData.GetNotNullClass>("invoice_source"); } init { this._rawData.Set("invoice_source", value); } } @@ -508,18 +504,18 @@ public required string? MinimumAmount /// /// A list of payment attempts associated with the invoice /// - public required IReadOnlyList PaymentAttempts + public required IReadOnlyList PaymentAttempts { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("payment_attempts"); + return this._rawData.GetNotNullStruct>( + "payment_attempts" + ); } init { - this._rawData.Set>( + this._rawData.Set>( "payment_attempts", ImmutableArray.ToImmutableArray(value) ); @@ -747,9 +743,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse(InvoiceFetchUpcomingResponse invoiceFetchUpcomingResponse) : base(invoiceFetchUpcomingResponse) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: discount")] public InvoiceFetchUpcomingResponse(IReadOnlyDictionary rawData) @@ -783,12 +782,7 @@ IReadOnlyDictionary rawData ) => InvoiceFetchUpcomingResponse.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.AutoCollection, - global::Orb.Models.Invoices.AutoCollectionFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class AutoCollection : JsonModel { /// @@ -863,8 +857,11 @@ public override void Validate() public AutoCollection() { } - public AutoCollection(global::Orb.Models.Invoices.AutoCollection autoCollection) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public AutoCollection(AutoCollection autoCollection) : base(autoCollection) { } +#pragma warning restore CS8618 public AutoCollection(IReadOnlyDictionary rawData) { @@ -879,29 +876,21 @@ public AutoCollection(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.AutoCollection FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static AutoCollection FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class AutoCollectionFromRaw : IFromRawJson +class AutoCollectionFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.AutoCollection FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.AutoCollection.FromRawUnchecked(rawData); + public AutoCollection FromRawUnchecked(IReadOnlyDictionary rawData) => + AutoCollection.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.CreditNote, - global::Orb.Models.Invoices.CreditNoteFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class CreditNote : JsonModel { public required string ID @@ -995,8 +984,11 @@ public override void Validate() public CreditNote() { } - public CreditNote(global::Orb.Models.Invoices.CreditNote creditNote) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CreditNote(CreditNote creditNote) : base(creditNote) { } +#pragma warning restore CS8618 public CreditNote(IReadOnlyDictionary rawData) { @@ -1011,28 +1003,22 @@ public CreditNote(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.CreditNote FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static CreditNote FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class CreditNoteFromRaw : IFromRawJson +class CreditNoteFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.CreditNote FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.CreditNote.FromRawUnchecked(rawData); + public CreditNote FromRawUnchecked(IReadOnlyDictionary rawData) => + CreditNote.FromRawUnchecked(rawData); } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.CustomerBalanceTransaction, - global::Orb.Models.Invoices.CustomerBalanceTransactionFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CustomerBalanceTransaction : JsonModel { @@ -1049,14 +1035,12 @@ public required string ID init { this._rawData.Set("id", value); } } - public required ApiEnum Action + public required ApiEnum Action { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("action"); + return this._rawData.GetNotNullClass>("action"); } init { this._rawData.Set("action", value); } } @@ -1176,10 +1160,11 @@ public override void Validate() public CustomerBalanceTransaction() { } - public CustomerBalanceTransaction( - global::Orb.Models.Invoices.CustomerBalanceTransaction customerBalanceTransaction - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CustomerBalanceTransaction(CustomerBalanceTransaction customerBalanceTransaction) : base(customerBalanceTransaction) { } +#pragma warning restore CS8618 public CustomerBalanceTransaction(IReadOnlyDictionary rawData) { @@ -1194,8 +1179,8 @@ public CustomerBalanceTransaction(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.CustomerBalanceTransaction FromRawUnchecked( + /// + public static CustomerBalanceTransaction FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1203,16 +1188,15 @@ IReadOnlyDictionary rawData } } -class CustomerBalanceTransactionFromRaw - : IFromRawJson +class CustomerBalanceTransactionFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.CustomerBalanceTransaction FromRawUnchecked( + public CustomerBalanceTransaction FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.CustomerBalanceTransaction.FromRawUnchecked(rawData); + ) => CustomerBalanceTransaction.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.ActionConverter))] +[JsonConverter(typeof(ActionConverter))] public enum Action { AppliedToInvoice, @@ -1227,9 +1211,9 @@ public enum Action SmallInvoiceCarryover, } -sealed class ActionConverter : JsonConverter +sealed class ActionConverter : JsonConverter { - public override global::Orb.Models.Invoices.Action Read( + public override Action Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1237,41 +1221,36 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "applied_to_invoice" => global::Orb.Models.Invoices.Action.AppliedToInvoice, - "manual_adjustment" => global::Orb.Models.Invoices.Action.ManualAdjustment, - "prorated_refund" => global::Orb.Models.Invoices.Action.ProratedRefund, - "revert_prorated_refund" => global::Orb.Models.Invoices.Action.RevertProratedRefund, - "return_from_voiding" => global::Orb.Models.Invoices.Action.ReturnFromVoiding, - "credit_note_applied" => global::Orb.Models.Invoices.Action.CreditNoteApplied, - "credit_note_voided" => global::Orb.Models.Invoices.Action.CreditNoteVoided, - "overpayment_refund" => global::Orb.Models.Invoices.Action.OverpaymentRefund, - "external_payment" => global::Orb.Models.Invoices.Action.ExternalPayment, - "small_invoice_carryover" => global::Orb.Models.Invoices.Action.SmallInvoiceCarryover, - _ => (global::Orb.Models.Invoices.Action)(-1), + "applied_to_invoice" => Action.AppliedToInvoice, + "manual_adjustment" => Action.ManualAdjustment, + "prorated_refund" => Action.ProratedRefund, + "revert_prorated_refund" => Action.RevertProratedRefund, + "return_from_voiding" => Action.ReturnFromVoiding, + "credit_note_applied" => Action.CreditNoteApplied, + "credit_note_voided" => Action.CreditNoteVoided, + "overpayment_refund" => Action.OverpaymentRefund, + "external_payment" => Action.ExternalPayment, + "small_invoice_carryover" => Action.SmallInvoiceCarryover, + _ => (Action)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Invoices.Action value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Action value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Invoices.Action.AppliedToInvoice => "applied_to_invoice", - global::Orb.Models.Invoices.Action.ManualAdjustment => "manual_adjustment", - global::Orb.Models.Invoices.Action.ProratedRefund => "prorated_refund", - global::Orb.Models.Invoices.Action.RevertProratedRefund => "revert_prorated_refund", - global::Orb.Models.Invoices.Action.ReturnFromVoiding => "return_from_voiding", - global::Orb.Models.Invoices.Action.CreditNoteApplied => "credit_note_applied", - global::Orb.Models.Invoices.Action.CreditNoteVoided => "credit_note_voided", - global::Orb.Models.Invoices.Action.OverpaymentRefund => "overpayment_refund", - global::Orb.Models.Invoices.Action.ExternalPayment => "external_payment", - global::Orb.Models.Invoices.Action.SmallInvoiceCarryover => - "small_invoice_carryover", + Action.AppliedToInvoice => "applied_to_invoice", + Action.ManualAdjustment => "manual_adjustment", + Action.ProratedRefund => "prorated_refund", + Action.RevertProratedRefund => "revert_prorated_refund", + Action.ReturnFromVoiding => "return_from_voiding", + Action.CreditNoteApplied => "credit_note_applied", + Action.CreditNoteVoided => "credit_note_voided", + Action.OverpaymentRefund => "overpayment_refund", + Action.ExternalPayment => "external_payment", + Action.SmallInvoiceCarryover => "small_invoice_carryover", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1281,7 +1260,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.TypeConverter))] +[JsonConverter(typeof(TypeConverter))] public enum Type { Increment, @@ -1325,7 +1304,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.InvoiceSourceConverter))] +[JsonConverter(typeof(InvoiceSourceConverter))] public enum InvoiceSource { Subscription, @@ -1333,9 +1312,9 @@ public enum InvoiceSource OneOff, } -sealed class InvoiceSourceConverter : JsonConverter +sealed class InvoiceSourceConverter : JsonConverter { - public override global::Orb.Models.Invoices.InvoiceSource Read( + public override InvoiceSource Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1343,16 +1322,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "subscription" => global::Orb.Models.Invoices.InvoiceSource.Subscription, - "partial" => global::Orb.Models.Invoices.InvoiceSource.Partial, - "one_off" => global::Orb.Models.Invoices.InvoiceSource.OneOff, - _ => (global::Orb.Models.Invoices.InvoiceSource)(-1), + "subscription" => InvoiceSource.Subscription, + "partial" => InvoiceSource.Partial, + "one_off" => InvoiceSource.OneOff, + _ => (InvoiceSource)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.InvoiceSource value, + InvoiceSource value, JsonSerializerOptions options ) { @@ -1360,9 +1339,9 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.InvoiceSource.Subscription => "subscription", - global::Orb.Models.Invoices.InvoiceSource.Partial => "partial", - global::Orb.Models.Invoices.InvoiceSource.OneOff => "one_off", + InvoiceSource.Subscription => "subscription", + InvoiceSource.Partial => "partial", + InvoiceSource.OneOff => "one_off", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -1409,21 +1388,19 @@ public required string AdjustedSubtotal /// /// All adjustments applied to the line item in the order they were applied based - /// on invoice calculations (ie. usage discounts -> amount discounts -> percentage - /// discounts -> minimums -> maximums). + /// on invoice calculations (ie. usage discounts -> amount discounts -> + /// percentage discounts -> minimums -> maximums). /// - public required IReadOnlyList Adjustments + public required IReadOnlyList Adjustments { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("adjustments"); + return this._rawData.GetNotNullStruct>("adjustments"); } init { - this._rawData.Set>( + this._rawData.Set>( "adjustments", ImmutableArray.ToImmutableArray(value) ); @@ -1575,18 +1552,16 @@ public required double Quantity /// For complex pricing structures, the line item can be broken down further /// in `sub_line_items`. /// - public required IReadOnlyList SubLineItems + public required IReadOnlyList SubLineItems { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("sub_line_items"); + return this._rawData.GetNotNullStruct>("sub_line_items"); } init { - this._rawData.Set>( + this._rawData.Set>( "sub_line_items", ImmutableArray.ToImmutableArray(value) ); @@ -1678,10 +1653,13 @@ public override void Validate() public InvoiceFetchUpcomingResponseLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceFetchUpcomingResponseLineItem( InvoiceFetchUpcomingResponseLineItem invoiceFetchUpcomingResponseLineItem ) : base(invoiceFetchUpcomingResponseLineItem) { } +#pragma warning restore CS8618 public InvoiceFetchUpcomingResponseLineItem(IReadOnlyDictionary rawData) { @@ -1714,7 +1692,7 @@ IReadOnlyDictionary rawData ) => InvoiceFetchUpcomingResponseLineItem.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Invoices.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -1841,7 +1819,7 @@ public Adjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1864,7 +1842,7 @@ public bool TryPickMonetaryUsageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1887,7 +1865,7 @@ public bool TryPickMonetaryAmountDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1910,7 +1888,7 @@ public bool TryPickMonetaryPercentageDiscount( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1931,7 +1909,7 @@ public bool TryPickMonetaryMinimum([NotNullWhen(true)] out MonetaryMinimumAdjust /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1951,7 +1929,7 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1962,11 +1940,11 @@ public bool TryPickMonetaryMaximum([NotNullWhen(true)] out MonetaryMaximumAdjust /// /// /// instance.Switch( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2005,7 +1983,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2016,11 +1994,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MonetaryUsageDiscountAdjustment value) => {...}, - /// (MonetaryAmountDiscountAdjustment value) => {...}, - /// (MonetaryPercentageDiscountAdjustment value) => {...}, - /// (MonetaryMinimumAdjustment value) => {...}, - /// (MonetaryMaximumAdjustment value) => {...} + /// (MonetaryUsageDiscountAdjustment value) => {...}, + /// (MonetaryAmountDiscountAdjustment value) => {...}, + /// (MonetaryPercentageDiscountAdjustment value) => {...}, + /// (MonetaryMinimumAdjustment value) => {...}, + /// (MonetaryMaximumAdjustment value) => {...} /// ); /// /// @@ -2044,25 +2022,17 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryUsageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryUsageDiscountAdjustment value) => new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryAmountDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryAmountDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryPercentageDiscountAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryPercentageDiscountAdjustment value) => + new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryMinimumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMinimumAdjustment value) => new(value); - public static implicit operator global::Orb.Models.Invoices.Adjustment( - MonetaryMaximumAdjustment value - ) => new(value); + public static implicit operator Adjustment(MonetaryMaximumAdjustment value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2089,10 +2059,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2100,12 +2070,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MonetaryUsageDiscountAdjustment _ => 0, + MonetaryAmountDiscountAdjustment _ => 1, + MonetaryPercentageDiscountAdjustment _ => 2, + MonetaryMinimumAdjustment _ => 3, + MonetaryMaximumAdjustment _ => 4, + _ => -1, + }; + } } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Invoices.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2134,12 +2120,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2156,12 +2140,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2179,12 +2161,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2201,12 +2181,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2223,12 +2201,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2237,14 +2213,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Invoices.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -2252,7 +2228,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(global::Orb.Models.Invoices.SubLineItemConverter))] +[JsonConverter(typeof(SubLineItemConverter))] public record class SubLineItem : ModelBase { public object? Value { get; } = null; @@ -2334,7 +2310,7 @@ public SubLineItem(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2355,7 +2331,7 @@ public bool TryPickMatrix([NotNullWhen(true)] out MatrixSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2376,7 +2352,7 @@ public bool TryPickTier([NotNullWhen(true)] out TierSubLineItem? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2396,7 +2372,7 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -2407,9 +2383,9 @@ public bool TryPickOther([NotNullWhen(true)] out OtherSubLineItem? value) /// /// /// instance.Switch( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2440,7 +2416,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -2451,9 +2427,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (MatrixSubLineItem value) => {...}, - /// (TierSubLineItem value) => {...}, - /// (OtherSubLineItem value) => {...} + /// (MatrixSubLineItem value) => {...}, + /// (TierSubLineItem value) => {...}, + /// (OtherSubLineItem value) => {...} /// ); /// /// @@ -2473,17 +2449,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - MatrixSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(MatrixSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - TierSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(TierSubLineItem value) => new(value); - public static implicit operator global::Orb.Models.Invoices.SubLineItem( - OtherSubLineItem value - ) => new(value); + public static implicit operator SubLineItem(OtherSubLineItem value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -2508,10 +2478,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Invoices.SubLineItem? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(SubLineItem? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -2519,12 +2489,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + MatrixSubLineItem _ => 0, + TierSubLineItem _ => 1, + OtherSubLineItem _ => 2, + _ => -1, + }; + } } -sealed class SubLineItemConverter : JsonConverter +sealed class SubLineItemConverter : JsonConverter { - public override global::Orb.Models.Invoices.SubLineItem? Read( + public override SubLineItem? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2553,12 +2537,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2575,12 +2557,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2597,12 +2577,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2611,14 +2589,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Invoices.SubLineItem(element); + return new SubLineItem(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.SubLineItem value, + SubLineItem value, JsonSerializerOptions options ) { @@ -2626,12 +2604,7 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Invoices.PaymentAttempt, - global::Orb.Models.Invoices.PaymentAttemptFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class PaymentAttempt : JsonModel { /// @@ -2676,14 +2649,14 @@ public required string Amount /// /// The payment provider that attempted to collect the payment. /// - public required ApiEnum? PaymentProvider + public required ApiEnum? PaymentProvider { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass< - ApiEnum - >("payment_provider"); + return this._rawData.GetNullableClass>( + "payment_provider" + ); } init { this._rawData.Set("payment_provider", value); } } @@ -2742,8 +2715,11 @@ public override void Validate() public PaymentAttempt() { } - public PaymentAttempt(global::Orb.Models.Invoices.PaymentAttempt paymentAttempt) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PaymentAttempt(PaymentAttempt paymentAttempt) : base(paymentAttempt) { } +#pragma warning restore CS8618 public PaymentAttempt(IReadOnlyDictionary rawData) { @@ -2758,35 +2734,32 @@ public PaymentAttempt(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Invoices.PaymentAttempt FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PaymentAttempt FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PaymentAttemptFromRaw : IFromRawJson +class PaymentAttemptFromRaw : IFromRawJson { /// - public global::Orb.Models.Invoices.PaymentAttempt FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Invoices.PaymentAttempt.FromRawUnchecked(rawData); + public PaymentAttempt FromRawUnchecked(IReadOnlyDictionary rawData) => + PaymentAttempt.FromRawUnchecked(rawData); } /// /// The payment provider that attempted to collect the payment. /// -[JsonConverter(typeof(global::Orb.Models.Invoices.PaymentProviderConverter))] +[JsonConverter(typeof(PaymentProviderConverter))] public enum PaymentProvider { Stripe, } -sealed class PaymentProviderConverter : JsonConverter +sealed class PaymentProviderConverter : JsonConverter { - public override global::Orb.Models.Invoices.PaymentProvider Read( + public override PaymentProvider Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -2794,14 +2767,14 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "stripe" => global::Orb.Models.Invoices.PaymentProvider.Stripe, - _ => (global::Orb.Models.Invoices.PaymentProvider)(-1), + "stripe" => PaymentProvider.Stripe, + _ => (PaymentProvider)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Invoices.PaymentProvider value, + PaymentProvider value, JsonSerializerOptions options ) { @@ -2809,7 +2782,7 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Invoices.PaymentProvider.Stripe => "stripe", + PaymentProvider.Stripe => "stripe", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Invoices/InvoiceIssueParams.cs b/src/Orb/Models/Invoices/InvoiceIssueParams.cs index 4a7427ed2..be154b13b 100644 --- a/src/Orb/Models/Invoices/InvoiceIssueParams.cs +++ b/src/Orb/Models/Invoices/InvoiceIssueParams.cs @@ -15,8 +15,12 @@ namespace Orb.Models.Invoices; /// is a time in the past. Issuing an invoice could possibly trigger side effects, /// some of which could be customer-visible (e.g. sending emails, auto-collecting /// payment, syncing the invoice to external providers, etc). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceIssueParams : ParamsBase +public record class InvoiceIssueParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -53,6 +57,8 @@ public bool? Synchronous public InvoiceIssueParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceIssueParams(InvoiceIssueParams invoiceIssueParams) : base(invoiceIssueParams) { @@ -60,6 +66,7 @@ public InvoiceIssueParams(InvoiceIssueParams invoiceIssueParams) this._rawBodyData = new(invoiceIssueParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceIssueParams( IReadOnlyDictionary rawHeaderData, @@ -77,27 +84,61 @@ IReadOnlyDictionary rawBodyData InvoiceIssueParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceIssueParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(InvoiceIssueParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -128,4 +169,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs new file mode 100644 index 000000000..ca64493be --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryParams.cs @@ -0,0 +1,180 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Invoices; + +/// +/// This endpoint allows an eligible invoice to be issued manually. This is only possible +/// with invoices where status is `draft`, `will_auto_issue` is false, and an `eligible_to_issue_at` +/// is a time in the past. Issuing an invoice could possibly trigger side effects, +/// some of which could be customer-visible (e.g. sending emails, auto-collecting +/// payment, syncing the invoice to external providers, etc). +/// +/// This is a lighter-weight alternative to the issue invoice endpoint, returning +/// an invoice summary without any line item details. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class InvoiceIssueSummaryParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? InvoiceID { get; init; } + + /// + /// If true, the invoice will be issued synchronously. If false, the invoice + /// will be issued asynchronously. The synchronous option is only available for + /// invoices that have no usage fees. If the invoice is configured to sync to + /// an external provider, a successful response from this endpoint guarantees + /// the invoice is present in the provider. + /// + public bool? Synchronous + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("synchronous"); + } + init + { + if (value == null) + { + return; + } + + this._rawBodyData.Set("synchronous", value); + } + } + + public InvoiceIssueSummaryParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryParams(InvoiceIssueSummaryParams invoiceIssueSummaryParams) + : base(invoiceIssueSummaryParams) + { + this.InvoiceID = invoiceIssueSummaryParams.InvoiceID; + + this._rawBodyData = new(invoiceIssueSummaryParams._rawBodyData); + } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData, + string invoiceID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string invoiceID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceIssueSummaryParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/invoices/summary/{0}/issue", this.InvoiceID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs b/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs new file mode 100644 index 000000000..f0b644e68 --- /dev/null +++ b/src/Orb/Models/Invoices/InvoiceIssueSummaryResponse.cs @@ -0,0 +1,1559 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Invoices; + +/// +/// #InvoiceApiResourceWithoutLineItems +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class InvoiceIssueSummaryResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// This is the final amount required to be charged to the customer and reflects + /// the application of the customer balance to the `total` of the invoice. + /// + public required string AmountDue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount_due"); + } + init { this._rawData.Set("amount_due", value); } + } + + public required InvoiceIssueSummaryResponseAutoCollection AutoCollection + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "auto_collection" + ); + } + init { this._rawData.Set("auto_collection", value); } + } + + public required Address? BillingAddress + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass
("billing_address"); + } + init { this._rawData.Set("billing_address", value); } + } + + /// + /// The creation time of the resource in Orb. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// A list of credit notes associated with the invoice + /// + public required IReadOnlyList CreditNotes + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("credit_notes"); + } + init + { + this._rawData.Set>( + "credit_notes", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// An ISO 4217 currency string or `credits` + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + public required CustomerMinified Customer + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("customer"); + } + init { this._rawData.Set("customer", value); } + } + + public required IReadOnlyList CustomerBalanceTransactions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("customer_balance_transactions"); + } + init + { + this._rawData.Set< + ImmutableArray + >("customer_balance_transactions", ImmutableArray.ToImmutableArray(value)); + } + } + + /// + /// Tax IDs are commonly required to be displayed on customer invoices, which + /// are added to the headers of invoices. + /// + /// ### Supported Tax ID Countries and Types + /// + /// | Country | Type | Description | |---------|------|-------------| | + /// Albania | `al_tin` | Albania Tax Identification Number | | Andorra | `ad_nrt` + /// | Andorran NRT Number | | Angola | `ao_tin` | Angola Tax Identification Number + /// | | Argentina | `ar_cuit` | Argentinian Tax ID Number | | Armenia | `am_tin` + /// | Armenia Tax Identification Number | | Aruba | `aw_tin` | Aruba Tax Identification + /// Number | | Australia | `au_abn` | Australian Business Number (AU ABN) | | + /// Australia | `au_arn` | Australian Taxation Office Reference Number | | Austria + /// | `eu_vat` | European VAT Number | | Azerbaijan | `az_tin` | Azerbaijan Tax + /// Identification Number | | Bahamas | `bs_tin` | Bahamas Tax Identification + /// Number | | Bahrain | `bh_vat` | Bahraini VAT Number | | Bangladesh | `bd_bin` + /// | Bangladesh Business Identification Number | | Barbados | `bb_tin` | Barbados + /// Tax Identification Number | | Belarus | `by_tin` | Belarus TIN Number | | + /// Belgium | `eu_vat` | European VAT Number | | Benin | `bj_ifu` | Benin Tax + /// Identification Number (Identifiant Fiscal Unique) | | Bolivia | `bo_tin` + /// | Bolivian Tax ID | | Bosnia and Herzegovina | `ba_tin` | Bosnia and Herzegovina + /// Tax Identification Number | | Brazil | `br_cnpj` | Brazilian CNPJ Number | + /// | Brazil | `br_cpf` | Brazilian CPF Number | | Bulgaria | `bg_uic` | Bulgaria + /// Unified Identification Code | | Bulgaria | `eu_vat` | European VAT Number + /// | | Burkina Faso | `bf_ifu` | Burkina Faso Tax Identification Number (Numéro + /// d'Identifiant Fiscal Unique) | | Cambodia | `kh_tin` | Cambodia Tax Identification + /// Number | | Cameroon | `cm_niu` | Cameroon Tax Identification Number (Numéro + /// d'Identifiant fiscal Unique) | | Canada | `ca_bn` | Canadian BN | | Canada + /// | `ca_gst_hst` | Canadian GST/HST Number | | Canada | `ca_pst_bc` | Canadian + /// PST Number (British Columbia) | | Canada | `ca_pst_mb` | Canadian PST Number + /// (Manitoba) | | Canada | `ca_pst_sk` | Canadian PST Number (Saskatchewan) | + /// | Canada | `ca_qst` | Canadian QST Number (Québec) | | Cape Verde | `cv_nif` + /// | Cape Verde Tax Identification Number (Número de Identificação Fiscal) | + /// | Chile | `cl_tin` | Chilean TIN | | China | `cn_tin` | Chinese Tax ID | | + /// Colombia | `co_nit` | Colombian NIT Number | | Congo-Kinshasa | `cd_nif` + /// | Congo (DR) Tax Identification Number (Número de Identificação Fiscal) | + /// | Costa Rica | `cr_tin` | Costa Rican Tax ID | | Croatia | `eu_vat` | European + /// VAT Number | | Croatia | `hr_oib` | Croatian Personal Identification Number + /// (OIB) | | Cyprus | `eu_vat` | European VAT Number | | Czech Republic | `eu_vat` + /// | European VAT Number | | Denmark | `eu_vat` | European VAT Number | | Dominican + /// Republic | `do_rcn` | Dominican RCN Number | | Ecuador | `ec_ruc` | Ecuadorian + /// RUC Number | | Egypt | `eg_tin` | Egyptian Tax Identification Number | | + /// El Salvador | `sv_nit` | El Salvadorian NIT Number | | Estonia | `eu_vat` + /// | European VAT Number | | Ethiopia | `et_tin` | Ethiopia Tax Identification + /// Number | | European Union | `eu_oss_vat` | European One Stop Shop VAT Number + /// for non-Union scheme | | Finland | `eu_vat` | European VAT Number | | France + /// | `eu_vat` | European VAT Number | | Georgia | `ge_vat` | Georgian VAT | | + /// Germany | `de_stn` | German Tax Number (Steuernummer) | | Germany | `eu_vat` + /// | European VAT Number | | Greece | `eu_vat` | European VAT Number | | Guinea + /// | `gn_nif` | Guinea Tax Identification Number (Número de Identificação Fiscal) + /// | | Hong Kong | `hk_br` | Hong Kong BR Number | | Hungary | `eu_vat` | European + /// VAT Number | | Hungary | `hu_tin` | Hungary Tax Number (adószám) | | Iceland + /// | `is_vat` | Icelandic VAT | | India | `in_gst` | Indian GST Number | | Indonesia + /// | `id_npwp` | Indonesian NPWP Number | | Ireland | `eu_vat` | European VAT + /// Number | | Israel | `il_vat` | Israel VAT | | Italy | `eu_vat` | European + /// VAT Number | | Japan | `jp_cn` | Japanese Corporate Number (*Hōjin Bangō*) + /// | | Japan | `jp_rn` | Japanese Registered Foreign Businesses' Registration + /// Number (*Tōroku Kokugai Jigyōsha no Tōroku Bangō*) | | Japan | `jp_trn` | + /// Japanese Tax Registration Number (*Tōroku Bangō*) | | Kazakhstan | `kz_bin` + /// | Kazakhstani Business Identification Number | | Kenya | `ke_pin` | Kenya + /// Revenue Authority Personal Identification Number | | Kyrgyzstan | `kg_tin` + /// | Kyrgyzstan Tax Identification Number | | Laos | `la_tin` | Laos Tax Identification + /// Number | | Latvia | `eu_vat` | European VAT Number | | Liechtenstein | `li_uid` + /// | Liechtensteinian UID Number | | Liechtenstein | `li_vat` | Liechtenstein + /// VAT Number | | Lithuania | `eu_vat` | European VAT Number | | Luxembourg + /// | `eu_vat` | European VAT Number | | Malaysia | `my_frp` | Malaysian FRP + /// Number | | Malaysia | `my_itn` | Malaysian ITN | | Malaysia | `my_sst` | Malaysian + /// SST Number | | Malta | `eu_vat` | European VAT Number | | Mauritania | `mr_nif` + /// | Mauritania Tax Identification Number (Número de Identificação Fiscal) | + /// | Mexico | `mx_rfc` | Mexican RFC Number | | Moldova | `md_vat` | Moldova + /// VAT Number | | Montenegro | `me_pib` | Montenegro PIB Number | | Morocco | + /// `ma_vat` | Morocco VAT Number | | Nepal | `np_pan` | Nepal PAN Number | | + /// Netherlands | `eu_vat` | European VAT Number | | New Zealand | `nz_gst` | + /// New Zealand GST Number | | Nigeria | `ng_tin` | Nigerian Tax Identification + /// Number | | North Macedonia | `mk_vat` | North Macedonia VAT Number | | Northern + /// Ireland | `eu_vat` | Northern Ireland VAT Number | | Norway | `no_vat` | + /// Norwegian VAT Number | | Norway | `no_voec` | Norwegian VAT on e-commerce + /// Number | | Oman | `om_vat` | Omani VAT Number | | Peru | `pe_ruc` | Peruvian + /// RUC Number | | Philippines | `ph_tin` | Philippines Tax Identification Number + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | + /// + public required CustomerTaxID? CustomerTaxID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("customer_tax_id"); + } + init { this._rawData.Set("customer_tax_id", value); } + } + + /// + /// When the invoice payment is due. The due date is null if the invoice is not + /// yet finalized. + /// + public required System::DateTimeOffset? DueDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("due_date"); + } + init { this._rawData.Set("due_date", value); } + } + + /// + /// If the invoice has a status of `draft`, this will be the time that the invoice + /// will be eligible to be issued, otherwise it will be `null`. If `auto-issue` + /// is true, the invoice will automatically begin issuing at this time. + /// + public required System::DateTimeOffset? EligibleToIssueAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("eligible_to_issue_at"); + } + init { this._rawData.Set("eligible_to_issue_at", value); } + } + + /// + /// A URL for the customer-facing invoice portal. This URL expires 30 days after + /// the invoice's due date, or 60 days after being re-generated through the UI. + /// + public required string? HostedInvoiceUrl + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("hosted_invoice_url"); + } + init { this._rawData.Set("hosted_invoice_url", value); } + } + + /// + /// The scheduled date of the invoice + /// + public required System::DateTimeOffset InvoiceDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("invoice_date"); + } + init { this._rawData.Set("invoice_date", value); } + } + + /// + /// Automatically generated invoice number to help track and reconcile invoices. + /// Invoice numbers have a prefix such as `RFOBWG`. These can be sequential per + /// account or customer. + /// + public required string InvoiceNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("invoice_number"); + } + init { this._rawData.Set("invoice_number", value); } + } + + /// + /// The link to download the PDF representation of the `Invoice`. + /// + public required string? InvoicePdf + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_pdf"); + } + init { this._rawData.Set("invoice_pdf", value); } + } + + public required ApiEnum InvoiceSource + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("invoice_source"); + } + init { this._rawData.Set("invoice_source", value); } + } + + /// + /// If the invoice failed to issue, this will be the last time it failed to issue + /// (even if it is now in a different state.) + /// + public required System::DateTimeOffset? IssueFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("issue_failed_at"); + } + init { this._rawData.Set("issue_failed_at", value); } + } + + /// + /// If the invoice has been issued, this will be the time it transitioned to + /// `issued` (even if it is now in a different state.) + /// + public required System::DateTimeOffset? IssuedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("issued_at"); + } + init { this._rawData.Set("issued_at", value); } + } + + /// + /// Free-form text which is available on the invoice PDF and the Orb invoice portal. + /// + public required string? Memo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("memo"); + } + init { this._rawData.Set("memo", value); } + } + + /// + /// User specified key-value pairs for the resource. If not present, this defaults + /// to an empty dictionary. Individual keys can be removed by setting the value + /// to `null`, and the entire metadata mapping can be cleared by setting `metadata` + /// to `null`. + /// + public required IReadOnlyDictionary Metadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>("metadata"); + } + init + { + this._rawData.Set>( + "metadata", + FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + + /// + /// If the invoice has a status of `paid`, this gives a timestamp when the invoice + /// was paid. + /// + public required System::DateTimeOffset? PaidAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("paid_at"); + } + init { this._rawData.Set("paid_at", value); } + } + + /// + /// A list of payment attempts associated with the invoice + /// + public required IReadOnlyList PaymentAttempts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("payment_attempts"); + } + init + { + this._rawData.Set>( + "payment_attempts", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// If payment was attempted on this invoice but failed, this will be the time + /// of the most recent attempt. + /// + public required System::DateTimeOffset? PaymentFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("payment_failed_at"); + } + init { this._rawData.Set("payment_failed_at", value); } + } + + /// + /// If payment was attempted on this invoice, this will be the start time of + /// the most recent attempt. This field is especially useful for delayed-notification + /// payment mechanisms (like bank transfers), where payment can take 3 days or more. + /// + public required System::DateTimeOffset? PaymentStartedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("payment_started_at"); + } + init { this._rawData.Set("payment_started_at", value); } + } + + /// + /// If the invoice is in draft, this timestamp will reflect when the invoice is + /// scheduled to be issued. + /// + public required System::DateTimeOffset? ScheduledIssueAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("scheduled_issue_at"); + } + init { this._rawData.Set("scheduled_issue_at", value); } + } + + public required Address? ShippingAddress + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass
("shipping_address"); + } + init { this._rawData.Set("shipping_address", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("status"); + } + init { this._rawData.Set("status", value); } + } + + public required SubscriptionMinified? Subscription + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("subscription"); + } + init { this._rawData.Set("subscription", value); } + } + + /// + /// If the invoice failed to sync, this will be the last time an external invoicing + /// provider sync was attempted. This field will always be `null` for invoices + /// using Orb Invoicing. + /// + public required System::DateTimeOffset? SyncFailedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("sync_failed_at"); + } + init { this._rawData.Set("sync_failed_at", value); } + } + + /// + /// The total after any minimums and discounts have been applied. + /// + public required string Total + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total"); + } + init { this._rawData.Set("total", value); } + } + + /// + /// If the invoice has a status of `void`, this gives a timestamp when the invoice + /// was voided. + /// + public required System::DateTimeOffset? VoidedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("voided_at"); + } + init { this._rawData.Set("voided_at", value); } + } + + /// + /// This is true if the invoice will be automatically issued in the future, and + /// false otherwise. + /// + public required bool WillAutoIssue + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("will_auto_issue"); + } + init { this._rawData.Set("will_auto_issue", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.AmountDue; + this.AutoCollection.Validate(); + this.BillingAddress?.Validate(); + _ = this.CreatedAt; + foreach (var item in this.CreditNotes) + { + item.Validate(); + } + _ = this.Currency; + this.Customer.Validate(); + foreach (var item in this.CustomerBalanceTransactions) + { + item.Validate(); + } + this.CustomerTaxID?.Validate(); + _ = this.DueDate; + _ = this.EligibleToIssueAt; + _ = this.HostedInvoiceUrl; + _ = this.InvoiceDate; + _ = this.InvoiceNumber; + _ = this.InvoicePdf; + this.InvoiceSource.Validate(); + _ = this.IssueFailedAt; + _ = this.IssuedAt; + _ = this.Memo; + _ = this.Metadata; + _ = this.PaidAt; + foreach (var item in this.PaymentAttempts) + { + item.Validate(); + } + _ = this.PaymentFailedAt; + _ = this.PaymentStartedAt; + _ = this.ScheduledIssueAt; + this.ShippingAddress?.Validate(); + this.Status.Validate(); + this.Subscription?.Validate(); + _ = this.SyncFailedAt; + _ = this.Total; + _ = this.VoidedAt; + _ = this.WillAutoIssue; + } + + public InvoiceIssueSummaryResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponse(InvoiceIssueSummaryResponse invoiceIssueSummaryResponse) + : base(invoiceIssueSummaryResponse) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseFromRaw : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponse.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseAutoCollection, + InvoiceIssueSummaryResponseAutoCollectionFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseAutoCollection : JsonModel +{ + /// + /// True only if auto-collection is enabled for this invoice. + /// + public required bool? Enabled + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("enabled"); + } + init { this._rawData.Set("enabled", value); } + } + + /// + /// If the invoice is scheduled for auto-collection, this field will reflect when + /// the next attempt will occur. If dunning has been exhausted, or auto-collection + /// is not enabled for this invoice, this field will be `null`. + /// + public required System::DateTimeOffset? NextAttemptAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("next_attempt_at"); + } + init { this._rawData.Set("next_attempt_at", value); } + } + + /// + /// Number of auto-collection payment attempts. + /// + public required long? NumAttempts + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("num_attempts"); + } + init { this._rawData.Set("num_attempts", value); } + } + + /// + /// If Orb has ever attempted payment auto-collection for this invoice, this field + /// will reflect when that attempt occurred. In conjunction with `next_attempt_at`, + /// this can be used to tell whether the invoice is currently in dunning (that + /// is, `previously_attempted_at` is non-null, and `next_attempt_time` is non-null), + /// or if dunning has been exhausted (`previously_attempted_at` is non-null, but + /// `next_attempt_time` is null). + /// + public required System::DateTimeOffset? PreviouslyAttemptedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct( + "previously_attempted_at" + ); + } + init { this._rawData.Set("previously_attempted_at", value); } + } + + /// + public override void Validate() + { + _ = this.Enabled; + _ = this.NextAttemptAt; + _ = this.NumAttempts; + _ = this.PreviouslyAttemptedAt; + } + + public InvoiceIssueSummaryResponseAutoCollection() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseAutoCollection( + InvoiceIssueSummaryResponseAutoCollection invoiceIssueSummaryResponseAutoCollection + ) + : base(invoiceIssueSummaryResponseAutoCollection) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseAutoCollection( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseAutoCollection(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseAutoCollection FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseAutoCollectionFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseAutoCollection FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseAutoCollection.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseCreditNote, + InvoiceIssueSummaryResponseCreditNoteFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseCreditNote : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required string CreditNoteNumber + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("credit_note_number"); + } + init { this._rawData.Set("credit_note_number", value); } + } + + /// + /// An optional memo supplied on the credit note. + /// + public required string? Memo + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("memo"); + } + init { this._rawData.Set("memo", value); } + } + + public required string Reason + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("reason"); + } + init { this._rawData.Set("reason", value); } + } + + public required string Total + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("total"); + } + init { this._rawData.Set("total", value); } + } + + public required string Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + /// If the credit note has a status of `void`, this gives a timestamp when the + /// credit note was voided. + /// + public required System::DateTimeOffset? VoidedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("voided_at"); + } + init { this._rawData.Set("voided_at", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.CreditNoteNumber; + _ = this.Memo; + _ = this.Reason; + _ = this.Total; + _ = this.Type; + _ = this.VoidedAt; + } + + public InvoiceIssueSummaryResponseCreditNote() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseCreditNote( + InvoiceIssueSummaryResponseCreditNote invoiceIssueSummaryResponseCreditNote + ) + : base(invoiceIssueSummaryResponseCreditNote) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseCreditNote(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseCreditNote(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseCreditNote FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseCreditNoteFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseCreditNote FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseCreditNote.FromRawUnchecked(rawData); +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponseCustomerBalanceTransaction, + InvoiceIssueSummaryResponseCustomerBalanceTransactionFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponseCustomerBalanceTransaction : JsonModel +{ + /// + /// A unique id for this transaction. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required ApiEnum< + string, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction + > Action + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("action"); + } + init { this._rawData.Set("action", value); } + } + + /// + /// The value of the amount changed in the transaction. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The creation time of this transaction. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + public required CreditNoteTiny? CreditNote + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("credit_note"); + } + init { this._rawData.Set("credit_note", value); } + } + + /// + /// An optional description provided for manual customer balance adjustments. + /// + public required string? Description + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("description"); + } + init { this._rawData.Set("description", value); } + } + + /// + /// The new value of the customer's balance prior to the transaction, in the customer's currency. + /// + public required string EndingBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("ending_balance"); + } + init { this._rawData.Set("ending_balance", value); } + } + + public required InvoiceTiny? Invoice + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice"); + } + init { this._rawData.Set("invoice", value); } + } + + /// + /// The original value of the customer's balance prior to the transaction, in + /// the customer's currency. + /// + public required string StartingBalance + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("starting_balance"); + } + init { this._rawData.Set("starting_balance", value); } + } + + public required ApiEnum Type + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("type"); + } + init { this._rawData.Set("type", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + this.Action.Validate(); + _ = this.Amount; + _ = this.CreatedAt; + this.CreditNote?.Validate(); + _ = this.Description; + _ = this.EndingBalance; + this.Invoice?.Validate(); + _ = this.StartingBalance; + this.Type.Validate(); + } + + public InvoiceIssueSummaryResponseCustomerBalanceTransaction() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponseCustomerBalanceTransaction( + InvoiceIssueSummaryResponseCustomerBalanceTransaction invoiceIssueSummaryResponseCustomerBalanceTransaction + ) + : base(invoiceIssueSummaryResponseCustomerBalanceTransaction) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponseCustomerBalanceTransaction( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponseCustomerBalanceTransaction( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponseCustomerBalanceTransaction FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponseCustomerBalanceTransactionFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponseCustomerBalanceTransaction FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponseCustomerBalanceTransaction.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseCustomerBalanceTransactionActionConverter))] +public enum InvoiceIssueSummaryResponseCustomerBalanceTransactionAction +{ + AppliedToInvoice, + ManualAdjustment, + ProratedRefund, + RevertProratedRefund, + ReturnFromVoiding, + CreditNoteApplied, + CreditNoteVoided, + OverpaymentRefund, + ExternalPayment, + SmallInvoiceCarryover, +} + +sealed class InvoiceIssueSummaryResponseCustomerBalanceTransactionActionConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseCustomerBalanceTransactionAction Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "applied_to_invoice" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice, + "manual_adjustment" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment, + "prorated_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund, + "revert_prorated_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund, + "return_from_voiding" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding, + "credit_note_applied" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied, + "credit_note_voided" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided, + "overpayment_refund" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund, + "external_payment" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment, + "small_invoice_carryover" => + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover, + _ => (InvoiceIssueSummaryResponseCustomerBalanceTransactionAction)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.AppliedToInvoice => + "applied_to_invoice", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ManualAdjustment => + "manual_adjustment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ProratedRefund => + "prorated_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.RevertProratedRefund => + "revert_prorated_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ReturnFromVoiding => + "return_from_voiding", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteApplied => + "credit_note_applied", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.CreditNoteVoided => + "credit_note_voided", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.OverpaymentRefund => + "overpayment_refund", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.ExternalPayment => + "external_payment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionAction.SmallInvoiceCarryover => + "small_invoice_carryover", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseCustomerBalanceTransactionTypeConverter))] +public enum InvoiceIssueSummaryResponseCustomerBalanceTransactionType +{ + Increment, + Decrement, +} + +sealed class InvoiceIssueSummaryResponseCustomerBalanceTransactionTypeConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseCustomerBalanceTransactionType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "increment" => InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment, + "decrement" => InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement, + _ => (InvoiceIssueSummaryResponseCustomerBalanceTransactionType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseCustomerBalanceTransactionType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Increment => "increment", + InvoiceIssueSummaryResponseCustomerBalanceTransactionType.Decrement => "decrement", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseInvoiceSourceConverter))] +public enum InvoiceIssueSummaryResponseInvoiceSource +{ + Subscription, + Partial, + OneOff, +} + +sealed class InvoiceIssueSummaryResponseInvoiceSourceConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseInvoiceSource Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "subscription" => InvoiceIssueSummaryResponseInvoiceSource.Subscription, + "partial" => InvoiceIssueSummaryResponseInvoiceSource.Partial, + "one_off" => InvoiceIssueSummaryResponseInvoiceSource.OneOff, + _ => (InvoiceIssueSummaryResponseInvoiceSource)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseInvoiceSource value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseInvoiceSource.Subscription => "subscription", + InvoiceIssueSummaryResponseInvoiceSource.Partial => "partial", + InvoiceIssueSummaryResponseInvoiceSource.OneOff => "one_off", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + InvoiceIssueSummaryResponsePaymentAttempt, + InvoiceIssueSummaryResponsePaymentAttemptFromRaw + >) +)] +public sealed record class InvoiceIssueSummaryResponsePaymentAttempt : JsonModel +{ + /// + /// The ID of the payment attempt. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The amount of the payment attempt. + /// + public required string Amount + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("amount"); + } + init { this._rawData.Set("amount", value); } + } + + /// + /// The time at which the payment attempt was created. + /// + public required System::DateTimeOffset CreatedAt + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("created_at"); + } + init { this._rawData.Set("created_at", value); } + } + + /// + /// The payment provider that attempted to collect the payment. + /// + public required ApiEnum< + string, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider + >? PaymentProvider + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass< + ApiEnum + >("payment_provider"); + } + init { this._rawData.Set("payment_provider", value); } + } + + /// + /// The ID of the payment attempt in the payment provider. + /// + public required string? PaymentProviderID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("payment_provider_id"); + } + init { this._rawData.Set("payment_provider_id", value); } + } + + /// + /// URL to the downloadable PDF version of the receipt. This field will be `null` + /// for payment attempts that did not succeed. + /// + public required string? ReceiptPdf + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("receipt_pdf"); + } + init { this._rawData.Set("receipt_pdf", value); } + } + + /// + /// Whether the payment attempt succeeded. + /// + public required bool Succeeded + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("succeeded"); + } + init { this._rawData.Set("succeeded", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.Amount; + _ = this.CreatedAt; + this.PaymentProvider?.Validate(); + _ = this.PaymentProviderID; + _ = this.ReceiptPdf; + _ = this.Succeeded; + } + + public InvoiceIssueSummaryResponsePaymentAttempt() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public InvoiceIssueSummaryResponsePaymentAttempt( + InvoiceIssueSummaryResponsePaymentAttempt invoiceIssueSummaryResponsePaymentAttempt + ) + : base(invoiceIssueSummaryResponsePaymentAttempt) { } +#pragma warning restore CS8618 + + public InvoiceIssueSummaryResponsePaymentAttempt( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + InvoiceIssueSummaryResponsePaymentAttempt(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static InvoiceIssueSummaryResponsePaymentAttempt FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class InvoiceIssueSummaryResponsePaymentAttemptFromRaw + : IFromRawJson +{ + /// + public InvoiceIssueSummaryResponsePaymentAttempt FromRawUnchecked( + IReadOnlyDictionary rawData + ) => InvoiceIssueSummaryResponsePaymentAttempt.FromRawUnchecked(rawData); +} + +/// +/// The payment provider that attempted to collect the payment. +/// +[JsonConverter(typeof(InvoiceIssueSummaryResponsePaymentAttemptPaymentProviderConverter))] +public enum InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider +{ + Stripe, +} + +sealed class InvoiceIssueSummaryResponsePaymentAttemptPaymentProviderConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "stripe" => InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe, + _ => (InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponsePaymentAttemptPaymentProvider.Stripe => "stripe", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(InvoiceIssueSummaryResponseStatusConverter))] +public enum InvoiceIssueSummaryResponseStatus +{ + Issued, + Paid, + Synced, + Void, + Draft, +} + +sealed class InvoiceIssueSummaryResponseStatusConverter + : JsonConverter +{ + public override InvoiceIssueSummaryResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "issued" => InvoiceIssueSummaryResponseStatus.Issued, + "paid" => InvoiceIssueSummaryResponseStatus.Paid, + "synced" => InvoiceIssueSummaryResponseStatus.Synced, + "void" => InvoiceIssueSummaryResponseStatus.Void, + "draft" => InvoiceIssueSummaryResponseStatus.Draft, + _ => (InvoiceIssueSummaryResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + InvoiceIssueSummaryResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + InvoiceIssueSummaryResponseStatus.Issued => "issued", + InvoiceIssueSummaryResponseStatus.Paid => "paid", + InvoiceIssueSummaryResponseStatus.Synced => "synced", + InvoiceIssueSummaryResponseStatus.Void => "void", + InvoiceIssueSummaryResponseStatus.Draft => "draft", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Invoices/InvoiceListPage.cs b/src/Orb/Models/Invoices/InvoiceListPage.cs index d663b4499..afd25c4d2 100644 --- a/src/Orb/Models/Invoices/InvoiceListPage.cs +++ b/src/Orb/Models/Invoices/InvoiceListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -62,5 +63,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not InvoiceListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Invoices/InvoiceListPageResponse.cs b/src/Orb/Models/Invoices/InvoiceListPageResponse.cs index 4c9bf2b41..830c24b93 100644 --- a/src/Orb/Models/Invoices/InvoiceListPageResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public InvoiceListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListPageResponse(InvoiceListPageResponse invoiceListPageResponse) : base(invoiceListPageResponse) { } +#pragma warning restore CS8618 public InvoiceListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Invoices/InvoiceListParams.cs b/src/Orb/Models/Invoices/InvoiceListParams.cs index 3abf3b01e..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..3d62887b4 100644 --- a/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs +++ b/src/Orb/Models/Invoices/InvoiceListSummaryResponse.cs @@ -218,31 +218,32 @@ public required IReadOnlyList + /// | | Poland | `eu_vat` | European VAT Number | | Poland | `pl_nip` | Polish + /// Tax ID Number | | Portugal | `eu_vat` | European VAT Number | | Romania | + /// `eu_vat` | European VAT Number | | Romania | `ro_tin` | Romanian Tax ID Number + /// | | Russia | `ru_inn` | Russian INN | | Russia | `ru_kpp` | Russian KPP | + /// | Saudi Arabia | `sa_vat` | Saudi Arabia VAT | | Senegal | `sn_ninea` | Senegal + /// NINEA Number | | Serbia | `rs_pib` | Serbian PIB Number | | Singapore | `sg_gst` + /// | Singaporean GST | | Singapore | `sg_uen` | Singaporean UEN | | Slovakia + /// | `eu_vat` | European VAT Number | | Slovenia | `eu_vat` | European VAT Number + /// | | Slovenia | `si_tin` | Slovenia Tax Number (davčna številka) | | South + /// Africa | `za_vat` | South African VAT Number | | South Korea | `kr_brn` | + /// Korean BRN | | Spain | `es_cif` | Spanish NIF Number (previously Spanish CIF + /// Number) | | Spain | `eu_vat` | European VAT Number | | Suriname | `sr_fin` + /// | Suriname FIN Number | | Sweden | `eu_vat` | European VAT Number | | Switzerland + /// | `ch_uid` | Switzerland UID Number | | Switzerland | `ch_vat` | Switzerland + /// VAT Number | | Taiwan | `tw_vat` | Taiwanese VAT | | Tajikistan | `tj_tin` + /// | Tajikistan Tax Identification Number | | Tanzania | `tz_vat` | Tanzania + /// VAT Number | | Thailand | `th_vat` | Thai VAT | | Turkey | `tr_tin` | Turkish + /// Tax Identification Number | | Uganda | `ug_tin` | Uganda Tax Identification + /// Number | | Ukraine | `ua_vat` | Ukrainian VAT | | United Arab Emirates | `ae_trn` + /// | United Arab Emirates TRN | | United Kingdom | `gb_vat` | United Kingdom + /// VAT Number | | United States | `us_ein` | United States EIN | | Uruguay | + /// `uy_ruc` | Uruguayan RUC Number | | Uzbekistan | `uz_tin` | Uzbekistan TIN + /// Number | | Uzbekistan | `uz_vat` | Uzbekistan VAT Number | | Venezuela | `ve_rif` + /// | Venezuelan RIF Number | | Vietnam | `vn_tin` | Vietnamese Tax ID Number + /// | | Zambia | `zm_tin` | Zambia Tax Identification Number | | Zimbabwe | `zw_tin` + /// | Zimbabwe Tax Identification Number | ///
public required CustomerTaxID? CustomerTaxID { @@ -628,8 +629,11 @@ public override void Validate() public InvoiceListSummaryResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponse(InvoiceListSummaryResponse invoiceListSummaryResponse) : base(invoiceListSummaryResponse) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponse(IReadOnlyDictionary rawData) { @@ -741,10 +745,13 @@ public override void Validate() public InvoiceListSummaryResponseAutoCollection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseAutoCollection( InvoiceListSummaryResponseAutoCollection invoiceListSummaryResponseAutoCollection ) : base(invoiceListSummaryResponseAutoCollection) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseAutoCollection( IReadOnlyDictionary rawData @@ -878,10 +885,13 @@ public override void Validate() public InvoiceListSummaryResponseCreditNote() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseCreditNote( InvoiceListSummaryResponseCreditNote invoiceListSummaryResponseCreditNote ) : base(invoiceListSummaryResponseCreditNote) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseCreditNote(IReadOnlyDictionary rawData) { @@ -1065,10 +1075,13 @@ public override void Validate() public InvoiceListSummaryResponseCustomerBalanceTransaction() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponseCustomerBalanceTransaction( InvoiceListSummaryResponseCustomerBalanceTransaction invoiceListSummaryResponseCustomerBalanceTransaction ) : base(invoiceListSummaryResponseCustomerBalanceTransaction) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponseCustomerBalanceTransaction( IReadOnlyDictionary rawData @@ -1406,10 +1419,13 @@ public override void Validate() public InvoiceListSummaryResponsePaymentAttempt() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceListSummaryResponsePaymentAttempt( InvoiceListSummaryResponsePaymentAttempt invoiceListSummaryResponsePaymentAttempt ) : base(invoiceListSummaryResponsePaymentAttempt) { } +#pragma warning restore CS8618 public InvoiceListSummaryResponsePaymentAttempt( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs index 0dd75ea13..f4c87be27 100644 --- a/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceMarkPaidParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Invoices; /// /// This endpoint allows an invoice's status to be set to the `paid` status. This /// can only be done to invoices that are in the `issued` or `synced` status. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceMarkPaidParams : ParamsBase +public record class InvoiceMarkPaidParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -64,6 +68,8 @@ public string? Notes public InvoiceMarkPaidParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceMarkPaidParams(InvoiceMarkPaidParams invoiceMarkPaidParams) : base(invoiceMarkPaidParams) { @@ -71,6 +77,7 @@ public InvoiceMarkPaidParams(InvoiceMarkPaidParams invoiceMarkPaidParams) this._rawBodyData = new(invoiceMarkPaidParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceMarkPaidParams( IReadOnlyDictionary rawHeaderData, @@ -88,27 +95,61 @@ IReadOnlyDictionary rawBodyData InvoiceMarkPaidParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceMarkPaidParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(InvoiceMarkPaidParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -139,4 +180,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoicePayParams.cs b/src/Orb/Models/Invoices/InvoicePayParams.cs index 58694581e..ab1e1d45e 100644 --- a/src/Orb/Models/Invoices/InvoicePayParams.cs +++ b/src/Orb/Models/Invoices/InvoicePayParams.cs @@ -3,58 +3,129 @@ using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Net.Http; +using System.Text; using System.Text.Json; using Orb.Core; namespace Orb.Models.Invoices; /// -/// This endpoint collects payment for an invoice using the customer's default payment -/// method. This action can only be taken on invoices with status "issued". +/// This endpoint collects payment for an invoice. By default, it uses the customer's +/// default payment method. Optionally, a shared payment token (SPT) can be provided +/// to pay using agent-granted credentials instead. This action can only be taken +/// on invoices with status "issued". +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoicePayParams : ParamsBase +public record class InvoicePayParams : ParamsBase { + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + public string? InvoiceID { get; init; } + /// + /// The ID of a shared payment token granted by an agent to use for this payment. + /// + public required string SharedPaymentTokenID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("shared_payment_token_id"); + } + init { this._rawBodyData.Set("shared_payment_token_id", value); } + } + public InvoicePayParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoicePayParams(InvoicePayParams invoicePayParams) : base(invoicePayParams) { this.InvoiceID = invoicePayParams.InvoiceID; + + this._rawBodyData = new(invoicePayParams._rawBodyData); } +#pragma warning restore CS8618 public InvoicePayParams( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); } #pragma warning disable CS8618 [SetsRequiredMembers] InvoicePayParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoicePayParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(InvoicePayParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -68,6 +139,15 @@ public override Uri Url(ClientOptions options) }.Uri; } + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) { ParamsBase.AddDefaultHeaders(request, options); @@ -76,4 +156,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs index f5727977b..192046e25 100644 --- a/src/Orb/Models/Invoices/InvoiceUpdateParams.cs +++ b/src/Orb/Models/Invoices/InvoiceUpdateParams.cs @@ -12,15 +12,19 @@ namespace Orb.Models.Invoices; /// -/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, and -/// `invoice_date` properties on an invoice. If you pass null for the metadata value, -/// it will clear any existing metadata for that invoice. +/// This endpoint allows you to update the `metadata`, `net_terms`, `due_date`, `invoice_date`, +/// and `auto_collection` properties on an invoice. If you pass null for the metadata +/// value, it will clear any existing metadata for that invoice. /// /// `metadata` can be modified regardless of invoice state. `net_terms`, `due_date`, -/// and `invoice_date` can only be modified if the invoice is in a `draft` state. -/// `invoice_date` can only be modified for non-subscription invoices. +/// `invoice_date`, and `auto_collection` can only be modified if the invoice is in +/// a `draft` state. `invoice_date` can only be modified for non-subscription invoices. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceUpdateParams : ParamsBase +public record class InvoiceUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -30,6 +34,21 @@ public IReadOnlyDictionary RawBodyData public string? InvoiceID { get; init; } + /// + /// Determines whether this invoice will automatically attempt to charge a saved + /// payment method, if any. Can only be modified on draft invoices. If not specified, + /// the invoice's existing setting is unchanged. + /// + public bool? AutoCollection + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableStruct("auto_collection"); + } + init { this._rawBodyData.Set("auto_collection", value); } + } + /// /// An optional custom due date for the invoice. If not set, the due date will /// be calculated based on the `net_terms` value. @@ -100,6 +119,8 @@ public long? NetTerms public InvoiceUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) : base(invoiceUpdateParams) { @@ -107,6 +128,7 @@ public InvoiceUpdateParams(InvoiceUpdateParams invoiceUpdateParams) this._rawBodyData = new(invoiceUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public InvoiceUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -124,27 +146,61 @@ IReadOnlyDictionary rawBodyData InvoiceUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + invoiceID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(InvoiceUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override System::Uri Url(ClientOptions options) @@ -174,6 +230,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -219,7 +280,7 @@ public InvoiceUpdateParamsDueDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -240,7 +301,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -260,7 +321,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -271,8 +332,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -301,7 +362,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -312,8 +373,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -358,10 +419,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceUpdateParamsDueDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceUpdateParamsDueDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -369,7 +430,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceUpdateParamsDueDateConverter : JsonConverter @@ -396,7 +470,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -458,7 +535,7 @@ public InvoiceDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -479,7 +556,7 @@ public bool TryPickDate([NotNullWhen(true)] out string? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -499,7 +576,7 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -510,8 +587,8 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// /// instance.Switch( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -538,7 +615,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -549,8 +626,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (string value) => {...}, - /// (System::DateTimeOffset value) => {...} + /// (string value) => {...}, + /// (System::DateTimeOffset value) => {...} /// ); /// /// @@ -590,10 +667,10 @@ public override void Validate() } } - public virtual bool Equals(InvoiceDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(InvoiceDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -601,7 +678,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + string _ => 0, + System::DateTimeOffset _ => 1, + _ => -1, + }; + } } sealed class InvoiceDateConverter : JsonConverter @@ -628,7 +718,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { diff --git a/src/Orb/Models/Invoices/InvoiceVoidParams.cs b/src/Orb/Models/Invoices/InvoiceVoidParams.cs index 63a9c88ec..376a434ba 100644 --- a/src/Orb/Models/Invoices/InvoiceVoidParams.cs +++ b/src/Orb/Models/Invoices/InvoiceVoidParams.cs @@ -20,18 +20,25 @@ namespace Orb.Models.Invoices; /// If the invoice was used to purchase a credit block, but the invoice is /// not yet paid, the credit block will be voided. If the invoice was created due /// to a top-up, the top-up will be disabled. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class InvoiceVoidParams : ParamsBase +public record class InvoiceVoidParams : ParamsBase { public string? InvoiceID { get; init; } public InvoiceVoidParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public InvoiceVoidParams(InvoiceVoidParams invoiceVoidParams) : base(invoiceVoidParams) { this.InvoiceID = invoiceVoidParams.InvoiceID; } +#pragma warning restore CS8618 public InvoiceVoidParams( IReadOnlyDictionary rawHeaderData, @@ -46,26 +53,58 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] InvoiceVoidParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string invoiceID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.InvoiceID = invoiceID; } #pragma warning restore CS8618 - /// + /// public static InvoiceVoidParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string invoiceID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + invoiceID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["InvoiceID"] = JsonSerializer.SerializeToElement(this.InvoiceID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(InvoiceVoidParams? other) + { + if (other == null) + { + return false; + } + return (this.InvoiceID?.Equals(other.InvoiceID) ?? other.InvoiceID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder( @@ -85,4 +124,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/ItemSlim.cs b/src/Orb/Models/ItemSlim.cs index 62da0419f..34f873937 100644 --- a/src/Orb/Models/ItemSlim.cs +++ b/src/Orb/Models/ItemSlim.cs @@ -48,8 +48,11 @@ public override void Validate() public ItemSlim() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemSlim(ItemSlim itemSlim) : base(itemSlim) { } +#pragma warning restore CS8618 public ItemSlim(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Items/Item.cs b/src/Orb/Models/Items/Item.cs index 7f83161d1..34fe0816c 100644 --- a/src/Orb/Models/Items/Item.cs +++ b/src/Orb/Models/Items/Item.cs @@ -130,8 +130,11 @@ public override void Validate() public Item() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Item(Item item) : base(item) { } +#pragma warning restore CS8618 public Item(IReadOnlyDictionary rawData) { @@ -207,8 +210,11 @@ public override void Validate() public ItemExternalConnection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemExternalConnection(ItemExternalConnection itemExternalConnection) : base(itemExternalConnection) { } +#pragma warning restore CS8618 public ItemExternalConnection(IReadOnlyDictionary rawData) { @@ -254,6 +260,7 @@ public enum ItemExternalConnectionExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ItemExternalConnectionExternalConnectionNameConverter @@ -275,6 +282,7 @@ JsonSerializerOptions options "avalara" => ItemExternalConnectionExternalConnectionName.Avalara, "anrok" => ItemExternalConnectionExternalConnectionName.Anrok, "numeral" => ItemExternalConnectionExternalConnectionName.Numeral, + "stripe_tax" => ItemExternalConnectionExternalConnectionName.StripeTax, _ => (ItemExternalConnectionExternalConnectionName)(-1), }; } @@ -297,6 +305,7 @@ JsonSerializerOptions options ItemExternalConnectionExternalConnectionName.Avalara => "avalara", ItemExternalConnectionExternalConnectionName.Anrok => "anrok", ItemExternalConnectionExternalConnectionName.Numeral => "numeral", + ItemExternalConnectionExternalConnectionName.StripeTax => "stripe_tax", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Items/ItemArchiveParams.cs b/src/Orb/Models/Items/ItemArchiveParams.cs index 9ae2118ac..9e1cf62e9 100644 --- a/src/Orb/Models/Items/ItemArchiveParams.cs +++ b/src/Orb/Models/Items/ItemArchiveParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Items; /// /// Archive item +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemArchiveParams : ParamsBase +public record class ItemArchiveParams : ParamsBase { public string? ItemID { get; init; } public ItemArchiveParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemArchiveParams(ItemArchiveParams itemArchiveParams) : base(itemArchiveParams) { this.ItemID = itemArchiveParams.ItemID; } +#pragma warning restore CS8618 public ItemArchiveParams( IReadOnlyDictionary rawHeaderData, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ItemArchiveParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemArchiveParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + itemID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ItemArchiveParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemCreateParams.cs b/src/Orb/Models/Items/ItemCreateParams.cs index 53f156719..6a7d6a7ae 100644 --- a/src/Orb/Models/Items/ItemCreateParams.cs +++ b/src/Orb/Models/Items/ItemCreateParams.cs @@ -11,8 +11,12 @@ namespace Orb.Models.Items; /// /// This endpoint is used to create an [Item](/core-concepts#item). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemCreateParams : ParamsBase +public record class ItemCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -58,11 +62,14 @@ public required string Name public ItemCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemCreateParams(ItemCreateParams itemCreateParams) : base(itemCreateParams) { this._rawBodyData = new(itemCreateParams._rawBodyData); } +#pragma warning restore CS8618 public ItemCreateParams( IReadOnlyDictionary rawHeaderData, @@ -89,7 +96,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static ItemCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -103,6 +110,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/items") @@ -128,4 +163,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemFetchParams.cs b/src/Orb/Models/Items/ItemFetchParams.cs index cd8f02363..07bfafbd4 100644 --- a/src/Orb/Models/Items/ItemFetchParams.cs +++ b/src/Orb/Models/Items/ItemFetchParams.cs @@ -10,18 +10,25 @@ namespace Orb.Models.Items; /// /// This endpoint returns an item identified by its item_id. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemFetchParams : ParamsBase +public record class ItemFetchParams : ParamsBase { public string? ItemID { get; init; } public ItemFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemFetchParams(ItemFetchParams itemFetchParams) : base(itemFetchParams) { this.ItemID = itemFetchParams.ItemID; } +#pragma warning restore CS8618 public ItemFetchParams( IReadOnlyDictionary rawHeaderData, @@ -36,24 +43,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] ItemFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + itemID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(ItemFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -74,4 +113,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemListPage.cs b/src/Orb/Models/Items/ItemListPage.cs index a336efff7..1918e973d 100644 --- a/src/Orb/Models/Items/ItemListPage.cs +++ b/src/Orb/Models/Items/ItemListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -62,5 +63,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not ItemListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Items/ItemListPageResponse.cs b/src/Orb/Models/Items/ItemListPageResponse.cs index ceb712bc6..f922fbfe8 100644 --- a/src/Orb/Models/Items/ItemListPageResponse.cs +++ b/src/Orb/Models/Items/ItemListPageResponse.cs @@ -46,8 +46,11 @@ public override void Validate() public ItemListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemListPageResponse(ItemListPageResponse itemListPageResponse) : base(itemListPageResponse) { } +#pragma warning restore CS8618 public ItemListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Items/ItemListParams.cs b/src/Orb/Models/Items/ItemListParams.cs index 5e12608f0..574d47a42 100644 --- a/src/Orb/Models/Items/ItemListParams.cs +++ b/src/Orb/Models/Items/ItemListParams.cs @@ -10,8 +10,12 @@ namespace Orb.Models.Items; /// /// This endpoint returns a list of all Items, ordered in descending order by creation time. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemListParams : ParamsBase +public record class ItemListParams : ParamsBase { /// /// Cursor for pagination. This can be populated by the `next_cursor` value returned @@ -50,8 +54,11 @@ public long? Limit public ItemListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemListParams(ItemListParams itemListParams) : base(itemListParams) { } +#pragma warning restore CS8618 public ItemListParams( IReadOnlyDictionary rawHeaderData, @@ -74,7 +81,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static ItemListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -86,6 +93,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/items") @@ -102,4 +135,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Items/ItemUpdateParams.cs b/src/Orb/Models/Items/ItemUpdateParams.cs index f2e3552ae..ff9e0e425 100644 --- a/src/Orb/Models/Items/ItemUpdateParams.cs +++ b/src/Orb/Models/Items/ItemUpdateParams.cs @@ -14,8 +14,12 @@ namespace Orb.Models.Items; /// /// This endpoint can be used to update properties on the Item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class ItemUpdateParams : ParamsBase +public record class ItemUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -78,6 +82,8 @@ public string? Name public ItemUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ItemUpdateParams(ItemUpdateParams itemUpdateParams) : base(itemUpdateParams) { @@ -85,6 +91,7 @@ public ItemUpdateParams(ItemUpdateParams itemUpdateParams) this._rawBodyData = new(itemUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public ItemUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -102,29 +109,63 @@ IReadOnlyDictionary rawBodyData ItemUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string itemID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.ItemID = itemID; } #pragma warning restore CS8618 - /// + /// public static ItemUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string itemID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + itemID ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ItemID"] = JsonSerializer.SerializeToElement(this.ItemID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ItemUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.ItemID?.Equals(other.ItemID) ?? other.ItemID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -152,6 +193,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -198,8 +244,11 @@ public override void Validate() public ExternalConnection() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ExternalConnection(ExternalConnection externalConnection) : base(externalConnection) { } +#pragma warning restore CS8618 public ExternalConnection(IReadOnlyDictionary rawData) { @@ -244,6 +293,7 @@ public enum ExternalConnectionName Avalara, Anrok, Numeral, + StripeTax, } sealed class ExternalConnectionNameConverter : JsonConverter @@ -264,6 +314,7 @@ JsonSerializerOptions options "avalara" => ExternalConnectionName.Avalara, "anrok" => ExternalConnectionName.Anrok, "numeral" => ExternalConnectionName.Numeral, + "stripe_tax" => ExternalConnectionName.StripeTax, _ => (ExternalConnectionName)(-1), }; } @@ -286,6 +337,7 @@ JsonSerializerOptions options ExternalConnectionName.Avalara => "avalara", ExternalConnectionName.Anrok => "anrok", ExternalConnectionName.Numeral => "numeral", + ExternalConnectionName.StripeTax => "stripe_tax", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs new file mode 100644 index 000000000..ceb0d6b45 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateParams.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint is used to create a new license type. +/// +/// License types are used to group licenses and define billing behavior. Each +/// license type has a name and a grouping key that determines how metrics are aggregated +/// for billing purposes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseTypeCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("grouping_key"); + } + init { this._rawBodyData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("name"); + } + init { this._rawBodyData.Set("name", value); } + } + + public LicenseTypeCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeCreateParams(LicenseTypeCreateParams licenseTypeCreateParams) + : base(licenseTypeCreateParams) + { + this._rawBodyData = new(licenseTypeCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseTypeCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseTypeCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/license_types") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs new file mode 100644 index 000000000..c600449ed --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeCreateResponse.cs @@ -0,0 +1,104 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeCreateResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeCreateResponse(LicenseTypeCreateResponse licenseTypeCreateResponse) + : base(licenseTypeCreateResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeCreateResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeCreateResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs new file mode 100644 index 000000000..c8553b9b2 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPage.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Services; + +namespace Orb.Models.LicenseTypes; + +/// +/// A single page from the paginated endpoint that queries. +/// +public sealed class LicenseTypeListPage( + ILicenseTypeServiceWithRawResponse service, + LicenseTypeListParams parameters, + LicenseTypeListPageResponse response +) : IPage +{ + /// + public IReadOnlyList Items + { + get { return response.Data; } + } + + /// + public bool HasNext() + { + try + { + return this.Items.Count > 0 && response.PaginationMetadata.NextCursor != null; + } + catch (OrbInvalidDataException) + { + // If accessing the response data to determine if there's a next page failed, then just + // assume there's no next page. + return false; + } + } + + /// + async Task> IPage.Next( + CancellationToken cancellationToken + ) => await this.Next(cancellationToken).ConfigureAwait(false); + + /// + public async Task Next(CancellationToken cancellationToken = default) + { + var nextCursor = + response.PaginationMetadata.NextCursor + ?? throw new InvalidOperationException("Cannot request next page"); + using var nextResponse = await service + .List(parameters with { Cursor = nextCursor }, cancellationToken) + .ConfigureAwait(false); + return await nextResponse.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public void Validate() + { + response.Validate(); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not LicenseTypeListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs new file mode 100644 index 000000000..fcdfbde5c --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListPageResponse.cs @@ -0,0 +1,88 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeListPageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public LicenseTypeListPageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListPageResponse(LicenseTypeListPageResponse licenseTypeListPageResponse) + : base(licenseTypeListPageResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeListPageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListPageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeListPageResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeListPageResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs new file mode 100644 index 000000000..9db9494fc --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListParams.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint returns a list of all license types configured for the account, +/// ordered in ascending order by creation time. +/// +/// License types are used to group licenses and define billing behavior. Each +/// license type has a name and a grouping key that determines how metrics are aggregated +/// for billing purposes. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseTypeListParams : ParamsBase +{ + /// + /// Cursor for pagination. This can be populated by the `next_cursor` value returned + /// from the initial request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// The number of items to fetch. Defaults to 20. + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + public LicenseTypeListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListParams(LicenseTypeListParams licenseTypeListParams) + : base(licenseTypeListParams) { } +#pragma warning restore CS8618 + + public LicenseTypeListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseTypeListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/license_types") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs new file mode 100644 index 000000000..b3f5fa6bd --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeListResponse.cs @@ -0,0 +1,102 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseTypeListResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeListResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeListResponse(LicenseTypeListResponse licenseTypeListResponse) + : base(licenseTypeListResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeListResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeListResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeListResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeListResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs new file mode 100644 index 000000000..aae4a47a9 --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveParams.cs @@ -0,0 +1,125 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// This endpoint returns a license type identified by its license_type_id. +/// +/// Use this endpoint to retrieve details about a specific license type, including +/// its name and grouping key. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseTypeRetrieveParams : ParamsBase +{ + public string? LicenseTypeID { get; init; } + + public LicenseTypeRetrieveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeRetrieveParams(LicenseTypeRetrieveParams licenseTypeRetrieveParams) + : base(licenseTypeRetrieveParams) + { + this.LicenseTypeID = licenseTypeRetrieveParams.LicenseTypeID; + } +#pragma warning restore CS8618 + + public LicenseTypeRetrieveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeRetrieveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + string licenseTypeID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseTypeID = licenseTypeID; + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseTypeID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseTypeID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseTypeID"] = JsonSerializer.SerializeToElement(this.LicenseTypeID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseTypeRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseTypeID?.Equals(other.LicenseTypeID) ?? other.LicenseTypeID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/license_types/{0}", this.LicenseTypeID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs new file mode 100644 index 000000000..e270f62ef --- /dev/null +++ b/src/Orb/Models/LicenseTypes/LicenseTypeRetrieveResponse.cs @@ -0,0 +1,104 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.LicenseTypes; + +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseTypeRetrieveResponse : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public LicenseTypeRetrieveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseTypeRetrieveResponse(LicenseTypeRetrieveResponse licenseTypeRetrieveResponse) + : base(licenseTypeRetrieveResponse) { } +#pragma warning restore CS8618 + + public LicenseTypeRetrieveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseTypeRetrieveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseTypeRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseTypeRetrieveResponseFromRaw : IFromRawJson +{ + /// + public LicenseTypeRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseTypeRetrieveResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs new file mode 100644 index 000000000..2eaec4c0c --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageParams.cs @@ -0,0 +1,240 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.ExternalLicenses; + +/// +/// Returns usage and remaining credits for a license identified by its external +/// license ID. +/// +/// Date range defaults to the current billing period if not specified. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class ExternalLicenseGetUsageParams : ParamsBase +{ + public string? ExternalLicenseID { get; init; } + + /// + /// The license type ID to filter licenses by. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The subscription ID to get license usage for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public ExternalLicenseGetUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExternalLicenseGetUsageParams( + ExternalLicenseGetUsageParams externalLicenseGetUsageParams + ) + : base(externalLicenseGetUsageParams) + { + this.ExternalLicenseID = externalLicenseGetUsageParams.ExternalLicenseID; + } +#pragma warning restore CS8618 + + public ExternalLicenseGetUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExternalLicenseGetUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + string externalLicenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.ExternalLicenseID = externalLicenseID; + } +#pragma warning restore CS8618 + + /// + public static ExternalLicenseGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string externalLicenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalLicenseID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalLicenseID"] = JsonSerializer.SerializeToElement( + this.ExternalLicenseID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(ExternalLicenseGetUsageParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalLicenseID?.Equals(other.ExternalLicenseID) + ?? other.ExternalLicenseID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/external_licenses/{0}/usage", this.ExternalLicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs new file mode 100644 index 000000000..fc83ac508 --- /dev/null +++ b/src/Orb/Models/Licenses/ExternalLicenses/ExternalLicenseGetUsageResponse.cs @@ -0,0 +1,309 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.ExternalLicenses; + +[JsonConverter( + typeof(JsonModelConverter< + ExternalLicenseGetUsageResponse, + ExternalLicenseGetUsageResponseFromRaw + >) +)] +public sealed record class ExternalLicenseGetUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public ExternalLicenseGetUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ExternalLicenseGetUsageResponse( + ExternalLicenseGetUsageResponse externalLicenseGetUsageResponse + ) + : base(externalLicenseGetUsageResponse) { } +#pragma warning restore CS8618 + + public ExternalLicenseGetUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ExternalLicenseGetUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ExternalLicenseGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ExternalLicenseGetUsageResponseFromRaw : IFromRawJson +{ + /// + public ExternalLicenseGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ExternalLicenseGetUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/LicenseCreateParams.cs b/src/Orb/Models/Licenses/LicenseCreateParams.cs new file mode 100644 index 000000000..64e19d532 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseCreateParams.cs @@ -0,0 +1,200 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to create a new license for a user. +/// +/// If a start date is provided, the license will be activated at the **start** +/// of the specified date in the customer's timezone. Otherwise, the activation time +/// will default to the **start** of the current day in the customer's timezone. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseCreateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + /// + /// The external identifier for the license. + /// + public required string ExternalLicenseID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("external_license_id"); + } + init { this._rawBodyData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("license_type_id"); + } + init { this._rawBodyData.Set("license_type_id", value); } + } + + public required string SubscriptionID + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNotNullClass("subscription_id"); + } + init { this._rawBodyData.Set("subscription_id", value); } + } + + /// + /// The end date of the license. If not provided, the license will remain active + /// until deactivated. + /// + public string? EndDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("end_date"); + } + init { this._rawBodyData.Set("end_date", value); } + } + + /// + /// The start date of the license. If not provided, defaults to start of day + /// today in the customer's timezone. + /// + public string? StartDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("start_date"); + } + init { this._rawBodyData.Set("start_date", value); } + } + + public LicenseCreateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseCreateParams(LicenseCreateParams licenseCreateParams) + : base(licenseCreateParams) + { + this._rawBodyData = new(licenseCreateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseCreateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseCreateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } +#pragma warning restore CS8618 + + /// + public static LicenseCreateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/licenses") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseCreateResponse.cs b/src/Orb/Models/Licenses/LicenseCreateResponse.cs new file mode 100644 index 000000000..a7a3e5090 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseCreateResponse.cs @@ -0,0 +1,179 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseCreateResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseCreateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseCreateResponse(LicenseCreateResponse licenseCreateResponse) + : base(licenseCreateResponse) { } +#pragma warning restore CS8618 + + public LicenseCreateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseCreateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseCreateResponseFromRaw : IFromRawJson +{ + /// + public LicenseCreateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseCreateResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseCreateResponseStatusConverter))] +public enum LicenseCreateResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseCreateResponseStatusConverter : JsonConverter +{ + public override LicenseCreateResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseCreateResponseStatus.Active, + "inactive" => LicenseCreateResponseStatus.Inactive, + _ => (LicenseCreateResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseCreateResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseCreateResponseStatus.Active => "active", + LicenseCreateResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseDeactivateParams.cs b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs new file mode 100644 index 000000000..076bc5fa4 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateParams.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to deactivate an existing license. +/// +/// If an end date is provided, the license will be deactivated at the **start** +/// of the specified date in the customer's timezone. Otherwise, the deactivation +/// time will default to the **end** of the current day in the customer's timezone. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseDeactivateParams : ParamsBase +{ + readonly JsonDictionary _rawBodyData = new(); + public IReadOnlyDictionary RawBodyData + { + get { return this._rawBodyData.Freeze(); } + } + + public string? LicenseID { get; init; } + + /// + /// The date to deactivate the license. If not provided, defaults to end of day + /// today in the customer's timezone. + /// + public string? EndDate + { + get + { + this._rawBodyData.Freeze(); + return this._rawBodyData.GetNullableClass("end_date"); + } + init { this._rawBodyData.Set("end_date", value); } + } + + public LicenseDeactivateParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseDeactivateParams(LicenseDeactivateParams licenseDeactivateParams) + : base(licenseDeactivateParams) + { + this.LicenseID = licenseDeactivateParams.LicenseID; + + this._rawBodyData = new(licenseDeactivateParams._rawBodyData); + } +#pragma warning restore CS8618 + + public LicenseDeactivateParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseDeactivateParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + FrozenDictionary rawBodyData, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this._rawBodyData = new(rawBodyData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseDeactivateParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + IReadOnlyDictionary rawBodyData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + FrozenDictionary.ToFrozenDictionary(rawBodyData), + licenseID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseDeactivateParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/{0}/deactivate", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override HttpContent? BodyContent() + { + return new StringContent( + JsonSerializer.Serialize(this.RawBodyData, ModelBase.SerializerOptions), + Encoding.UTF8, + "application/json" + ); + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs b/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs new file mode 100644 index 000000000..2e6daef7d --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseDeactivateResponse.cs @@ -0,0 +1,182 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class LicenseDeactivateResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseDeactivateResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseDeactivateResponse(LicenseDeactivateResponse licenseDeactivateResponse) + : base(licenseDeactivateResponse) { } +#pragma warning restore CS8618 + + public LicenseDeactivateResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseDeactivateResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseDeactivateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseDeactivateResponseFromRaw : IFromRawJson +{ + /// + public LicenseDeactivateResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseDeactivateResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseDeactivateResponseStatusConverter))] +public enum LicenseDeactivateResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseDeactivateResponseStatusConverter + : JsonConverter +{ + public override LicenseDeactivateResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseDeactivateResponseStatus.Active, + "inactive" => LicenseDeactivateResponseStatus.Inactive, + _ => (LicenseDeactivateResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseDeactivateResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseDeactivateResponseStatus.Active => "active", + LicenseDeactivateResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseListPage.cs b/src/Orb/Models/Licenses/LicenseListPage.cs new file mode 100644 index 000000000..90a608a0c --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListPage.cs @@ -0,0 +1,83 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text.Json; +using System.Threading; +using System.Threading.Tasks; +using Orb.Core; +using Orb.Exceptions; +using Orb.Services; + +namespace Orb.Models.Licenses; + +/// +/// A single page from the paginated endpoint that queries. +/// +public sealed class LicenseListPage( + ILicenseServiceWithRawResponse service, + LicenseListParams parameters, + LicenseListPageResponse response +) : IPage +{ + /// + public IReadOnlyList Items + { + get { return response.Data; } + } + + /// + public bool HasNext() + { + try + { + return this.Items.Count > 0 && response.PaginationMetadata.NextCursor != null; + } + catch (OrbInvalidDataException) + { + // If accessing the response data to determine if there's a next page failed, then just + // assume there's no next page. + return false; + } + } + + /// + async Task> IPage.Next( + CancellationToken cancellationToken + ) => await this.Next(cancellationToken).ConfigureAwait(false); + + /// + public async Task Next(CancellationToken cancellationToken = default) + { + var nextCursor = + response.PaginationMetadata.NextCursor + ?? throw new InvalidOperationException("Cannot request next page"); + using var nextResponse = await service + .List(parameters with { Cursor = nextCursor }, cancellationToken) + .ConfigureAwait(false); + return await nextResponse.Deserialize(cancellationToken).ConfigureAwait(false); + } + + /// + public void Validate() + { + response.Validate(); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not LicenseListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; +} diff --git a/src/Orb/Models/Licenses/LicenseListPageResponse.cs b/src/Orb/Models/Licenses/LicenseListPageResponse.cs new file mode 100644 index 000000000..4079dc8a6 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListPageResponse.cs @@ -0,0 +1,86 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseListPageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public LicenseListPageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListPageResponse(LicenseListPageResponse licenseListPageResponse) + : base(licenseListPageResponse) { } +#pragma warning restore CS8618 + + public LicenseListPageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListPageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseListPageResponseFromRaw : IFromRawJson +{ + /// + public LicenseListPageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseListPageResponse.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/LicenseListParams.cs b/src/Orb/Models/Licenses/LicenseListParams.cs new file mode 100644 index 000000000..be88e4d9c --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListParams.cs @@ -0,0 +1,225 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint returns a list of all licenses for a subscription. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseListParams : ParamsBase +{ + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Cursor for pagination. This can be populated by the `next_cursor` value returned + /// from the initial request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + public string? ExternalLicenseID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("external_license_id"); + } + init { this._rawQueryData.Set("external_license_id", value); } + } + + public string? LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The number of items to fetch. Defaults to 20. + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + public ApiEnum? Status + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass>("status"); + } + init { this._rawQueryData.Set("status", value); } + } + + public LicenseListParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListParams(LicenseListParams licenseListParams) + : base(licenseListParams) { } +#pragma warning restore CS8618 + + public LicenseListParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override System::Uri Url(ClientOptions options) + { + return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/licenses") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} + +[JsonConverter(typeof(StatusConverter))] +public enum Status +{ + Active, + Inactive, +} + +sealed class StatusConverter : JsonConverter +{ + public override Status Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => Status.Active, + "inactive" => Status.Inactive, + _ => (Status)(-1), + }; + } + + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) + { + JsonSerializer.Serialize( + writer, + value switch + { + Status.Active => "active", + Status.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseListResponse.cs b/src/Orb/Models/Licenses/LicenseListResponse.cs new file mode 100644 index 000000000..6c6f6061f --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseListResponse.cs @@ -0,0 +1,178 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseListResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseListResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseListResponse(LicenseListResponse licenseListResponse) + : base(licenseListResponse) { } +#pragma warning restore CS8618 + + public LicenseListResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseListResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseListResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseListResponseFromRaw : IFromRawJson +{ + /// + public LicenseListResponse FromRawUnchecked(IReadOnlyDictionary rawData) => + LicenseListResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseListResponseStatusConverter))] +public enum LicenseListResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseListResponseStatusConverter : JsonConverter +{ + public override LicenseListResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseListResponseStatus.Active, + "inactive" => LicenseListResponseStatus.Inactive, + _ => (LicenseListResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseListResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseListResponseStatus.Active => "active", + LicenseListResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs new file mode 100644 index 000000000..c3766a266 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDParams.cs @@ -0,0 +1,155 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to fetch a license given an external license identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseRetrieveByExternalIDParams : ParamsBase +{ + public string? ExternalLicenseID { get; init; } + + /// + /// The ID of the license type to fetch the license for. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The ID of the subscription to fetch the license for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + public LicenseRetrieveByExternalIDParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveByExternalIDParams( + LicenseRetrieveByExternalIDParams licenseRetrieveByExternalIDParams + ) + : base(licenseRetrieveByExternalIDParams) + { + this.ExternalLicenseID = licenseRetrieveByExternalIDParams.ExternalLicenseID; + } +#pragma warning restore CS8618 + + public LicenseRetrieveByExternalIDParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveByExternalIDParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + string externalLicenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.ExternalLicenseID = externalLicenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveByExternalIDParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string externalLicenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + externalLicenseID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["ExternalLicenseID"] = JsonSerializer.SerializeToElement( + this.ExternalLicenseID + ), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseRetrieveByExternalIDParams? other) + { + if (other == null) + { + return false; + } + return ( + this.ExternalLicenseID?.Equals(other.ExternalLicenseID) + ?? other.ExternalLicenseID == null + ) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/external_license_id/{0}", this.ExternalLicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs new file mode 100644 index 000000000..5c47163e5 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveByExternalIDResponse.cs @@ -0,0 +1,187 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter( + typeof(JsonModelConverter< + LicenseRetrieveByExternalIDResponse, + LicenseRetrieveByExternalIDResponseFromRaw + >) +)] +public sealed record class LicenseRetrieveByExternalIDResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("status"); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseRetrieveByExternalIDResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveByExternalIDResponse( + LicenseRetrieveByExternalIDResponse licenseRetrieveByExternalIDResponse + ) + : base(licenseRetrieveByExternalIDResponse) { } +#pragma warning restore CS8618 + + public LicenseRetrieveByExternalIDResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveByExternalIDResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveByExternalIDResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseRetrieveByExternalIDResponseFromRaw : IFromRawJson +{ + /// + public LicenseRetrieveByExternalIDResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseRetrieveByExternalIDResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseRetrieveByExternalIDResponseStatusConverter))] +public enum LicenseRetrieveByExternalIDResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseRetrieveByExternalIDResponseStatusConverter + : JsonConverter +{ + public override LicenseRetrieveByExternalIDResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseRetrieveByExternalIDResponseStatus.Active, + "inactive" => LicenseRetrieveByExternalIDResponseStatus.Inactive, + _ => (LicenseRetrieveByExternalIDResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseRetrieveByExternalIDResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseRetrieveByExternalIDResponseStatus.Active => "active", + LicenseRetrieveByExternalIDResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveParams.cs b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs new file mode 100644 index 000000000..3feeed6b8 --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveParams.cs @@ -0,0 +1,121 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses; + +/// +/// This endpoint is used to fetch a license given an identifier. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class LicenseRetrieveParams : ParamsBase +{ + public string? LicenseID { get; init; } + + public LicenseRetrieveParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveParams(LicenseRetrieveParams licenseRetrieveParams) + : base(licenseRetrieveParams) + { + this.LicenseID = licenseRetrieveParams.LicenseID; + } +#pragma warning restore CS8618 + + public LicenseRetrieveParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(LicenseRetrieveParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + string.Format("/licenses/{0}", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs b/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs new file mode 100644 index 000000000..cb35e127d --- /dev/null +++ b/src/Orb/Models/Licenses/LicenseRetrieveResponse.cs @@ -0,0 +1,179 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; +using Orb.Exceptions; +using System = System; + +namespace Orb.Models.Licenses; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class LicenseRetrieveResponse : JsonModel +{ + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + public required System::DateTimeOffset? EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + public required string ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + public required System::DateTimeOffset StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + public required ApiEnum Status + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "status" + ); + } + init { this._rawData.Set("status", value); } + } + + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.EndDate; + _ = this.ExternalLicenseID; + _ = this.LicenseTypeID; + _ = this.StartDate; + this.Status.Validate(); + _ = this.SubscriptionID; + } + + public LicenseRetrieveResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public LicenseRetrieveResponse(LicenseRetrieveResponse licenseRetrieveResponse) + : base(licenseRetrieveResponse) { } +#pragma warning restore CS8618 + + public LicenseRetrieveResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + LicenseRetrieveResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static LicenseRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class LicenseRetrieveResponseFromRaw : IFromRawJson +{ + /// + public LicenseRetrieveResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => LicenseRetrieveResponse.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(LicenseRetrieveResponseStatusConverter))] +public enum LicenseRetrieveResponseStatus +{ + Active, + Inactive, +} + +sealed class LicenseRetrieveResponseStatusConverter : JsonConverter +{ + public override LicenseRetrieveResponseStatus Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "active" => LicenseRetrieveResponseStatus.Active, + "inactive" => LicenseRetrieveResponseStatus.Inactive, + _ => (LicenseRetrieveResponseStatus)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + LicenseRetrieveResponseStatus value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + LicenseRetrieveResponseStatus.Active => "active", + LicenseRetrieveResponseStatus.Inactive => "inactive", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs new file mode 100644 index 000000000..ff9bfee8c --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageParams.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +/// +/// Returns usage and remaining credits for all licenses of a given type on a subscription. +/// +/// Date range defaults to the current billing period if not specified. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UsageGetAllUsageParams : ParamsBase +{ + /// + /// The license type ID to filter licenses by. + /// + public required string LicenseTypeID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("license_type_id"); + } + init { this._rawQueryData.Set("license_type_id", value); } + } + + /// + /// The subscription ID to get license usage for. + /// + public required string SubscriptionID + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNotNullClass("subscription_id"); + } + init { this._rawQueryData.Set("subscription_id", value); } + } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public UsageGetAllUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetAllUsageParams(UsageGetAllUsageParams usageGetAllUsageParams) + : base(usageGetAllUsageParams) { } +#pragma warning restore CS8618 + + public UsageGetAllUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetAllUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetAllUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData) + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageGetAllUsageParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/licenses/usage") + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs new file mode 100644 index 000000000..d2d50c3d8 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetAllUsageResponse.cs @@ -0,0 +1,304 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UsageGetAllUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>("data"); + } + init + { + this._rawData.Set>("data", ImmutableArray.ToImmutableArray(value)); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public UsageGetAllUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetAllUsageResponse(UsageGetAllUsageResponse usageGetAllUsageResponse) + : base(usageGetAllUsageResponse) { } +#pragma warning restore CS8618 + + public UsageGetAllUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetAllUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetAllUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetAllUsageResponseFromRaw : IFromRawJson +{ + /// + public UsageGetAllUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetAllUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class Data : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public Data() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Data(Data data) + : base(data) { } +#pragma warning restore CS8618 + + public Data(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + Data(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static Data FromRawUnchecked(IReadOnlyDictionary rawData) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DataFromRaw : IFromRawJson +{ + /// + public Data FromRawUnchecked(IReadOnlyDictionary rawData) => + Data.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs new file mode 100644 index 000000000..82f4835e5 --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageParams.cs @@ -0,0 +1,206 @@ +using System; +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Net.Http; +using System.Text.Json; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +/// +/// Returns usage and remaining credits for a specific license over a date range. +/// +/// Date range defaults to the current billing period if not specified. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. +/// +public record class UsageGetUsageParams : ParamsBase +{ + public string? LicenseID { get; init; } + + /// + /// Pagination cursor from a previous request. + /// + public string? Cursor + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("cursor"); + } + init { this._rawQueryData.Set("cursor", value); } + } + + /// + /// End date for the usage period (YYYY-MM-DD). Defaults to end of current billing period. + /// + public string? EndDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("end_date"); + } + init { this._rawQueryData.Set("end_date", value); } + } + + /// + /// How to group the results. Valid values: 'license', 'day'. Can be combined + /// (e.g., 'license,day'). + /// + public IReadOnlyList? GroupBy + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct>("group_by"); + } + init + { + this._rawQueryData.Set?>( + "group_by", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// + /// Maximum number of rows in the response data (default 20, max 100). + /// + public long? Limit + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableStruct("limit"); + } + init + { + if (value == null) + { + return; + } + + this._rawQueryData.Set("limit", value); + } + } + + /// + /// Start date for the usage period (YYYY-MM-DD). Defaults to start of current + /// billing period. + /// + public string? StartDate + { + get + { + this._rawQueryData.Freeze(); + return this._rawQueryData.GetNullableClass("start_date"); + } + init { this._rawQueryData.Set("start_date", value); } + } + + public UsageGetUsageParams() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageParams(UsageGetUsageParams usageGetUsageParams) + : base(usageGetUsageParams) + { + this.LicenseID = usageGetUsageParams.LicenseID; + } +#pragma warning restore CS8618 + + public UsageGetUsageParams( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageParams( + FrozenDictionary rawHeaderData, + FrozenDictionary rawQueryData, + string licenseID + ) + { + this._rawHeaderData = new(rawHeaderData); + this._rawQueryData = new(rawQueryData); + this.LicenseID = licenseID; + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageParams FromRawUnchecked( + IReadOnlyDictionary rawHeaderData, + IReadOnlyDictionary rawQueryData, + string licenseID + ) + { + return new( + FrozenDictionary.ToFrozenDictionary(rawHeaderData), + FrozenDictionary.ToFrozenDictionary(rawQueryData), + licenseID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["LicenseID"] = JsonSerializer.SerializeToElement(this.LicenseID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(UsageGetUsageParams? other) + { + if (other == null) + { + return false; + } + return (this.LicenseID?.Equals(other.LicenseID) ?? other.LicenseID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + + public override Uri Url(ClientOptions options) + { + return new UriBuilder( + options.BaseUrl.ToString().TrimEnd('/') + + string.Format("/licenses/{0}/usage", this.LicenseID) + ) + { + Query = this.QueryString(options), + }.Uri; + } + + internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOptions options) + { + ParamsBase.AddDefaultHeaders(request, options); + foreach (var item in this.RawHeaderData) + { + ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); + } + } + + public override int GetHashCode() + { + return 0; + } +} diff --git a/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs b/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs new file mode 100644 index 000000000..47a383f1c --- /dev/null +++ b/src/Orb/Models/Licenses/Usage/UsageGetUsageResponse.cs @@ -0,0 +1,312 @@ +using System.Collections.Frozen; +using System.Collections.Generic; +using System.Collections.Immutable; +using System.Diagnostics.CodeAnalysis; +using System.Text.Json; +using System.Text.Json.Serialization; +using Orb.Core; + +namespace Orb.Models.Licenses.Usage; + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class UsageGetUsageResponse : JsonModel +{ + public required IReadOnlyList Data + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct>( + "data" + ); + } + init + { + this._rawData.Set>( + "data", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + public required PaginationMetadata PaginationMetadata + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pagination_metadata"); + } + init { this._rawData.Set("pagination_metadata", value); } + } + + /// + public override void Validate() + { + foreach (var item in this.Data) + { + item.Validate(); + } + this.PaginationMetadata.Validate(); + } + + public UsageGetUsageResponse() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageResponse(UsageGetUsageResponse usageGetUsageResponse) + : base(usageGetUsageResponse) { } +#pragma warning restore CS8618 + + public UsageGetUsageResponse(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageResponse(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetUsageResponseFromRaw : IFromRawJson +{ + /// + public UsageGetUsageResponse FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetUsageResponse.FromRawUnchecked(rawData); +} + +/// +/// The LicenseUsage resource represents usage and remaining credits for a license +/// over a date range. +/// +/// When grouped by 'day' only, license_id and external_license_id will be +/// null as the data is aggregated across all licenses. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UsageGetUsageResponseData : JsonModel +{ + /// + /// The total credits allocated to this license for the period. + /// + public required double AllocatedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("allocated_credits"); + } + init { this._rawData.Set("allocated_credits", value); } + } + + /// + /// The credits consumed by this license for the period. + /// + public required double ConsumedCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("consumed_credits"); + } + init { this._rawData.Set("consumed_credits", value); } + } + + /// + /// The end date of the usage period. + /// + public required string EndDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("end_date"); + } + init { this._rawData.Set("end_date", value); } + } + + /// + /// The unique identifier for the license type. + /// + public required string LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// The pricing unit for the credits (e.g., 'credits'). + /// + public required string PricingUnit + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("pricing_unit"); + } + init { this._rawData.Set("pricing_unit", value); } + } + + /// + /// The remaining credits available for this license (allocated - consumed). + /// + public required double RemainingCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("remaining_credits"); + } + init { this._rawData.Set("remaining_credits", value); } + } + + /// + /// The start date of the usage period. + /// + public required string StartDate + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("start_date"); + } + init { this._rawData.Set("start_date", value); } + } + + /// + /// The unique identifier for the subscription. + /// + public required string SubscriptionID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("subscription_id"); + } + init { this._rawData.Set("subscription_id", value); } + } + + /// + /// Credits consumed while the license was active (eligible for individual allocation deduction). + /// + public double? AllocationEligibleCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("allocation_eligible_credits"); + } + init { this._rawData.Set("allocation_eligible_credits", value); } + } + + /// + /// The external identifier for the license. Null when grouped by day only. + /// + public string? ExternalLicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("external_license_id"); + } + init { this._rawData.Set("external_license_id", value); } + } + + /// + /// The unique identifier for the license. Null when grouped by day only. + /// + public string? LicenseID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_id"); + } + init { this._rawData.Set("license_id", value); } + } + + /// + /// Credits consumed while the license was inactive (draws from shared pool, not + /// individual allocation). + /// + public double? SharedPoolCredits + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct("shared_pool_credits"); + } + init { this._rawData.Set("shared_pool_credits", value); } + } + + /// + public override void Validate() + { + _ = this.AllocatedCredits; + _ = this.ConsumedCredits; + _ = this.EndDate; + _ = this.LicenseTypeID; + _ = this.PricingUnit; + _ = this.RemainingCredits; + _ = this.StartDate; + _ = this.SubscriptionID; + _ = this.AllocationEligibleCredits; + _ = this.ExternalLicenseID; + _ = this.LicenseID; + _ = this.SharedPoolCredits; + } + + public UsageGetUsageResponseData() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UsageGetUsageResponseData(UsageGetUsageResponseData usageGetUsageResponseData) + : base(usageGetUsageResponseData) { } +#pragma warning restore CS8618 + + public UsageGetUsageResponseData(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UsageGetUsageResponseData(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UsageGetUsageResponseData FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UsageGetUsageResponseDataFromRaw : IFromRawJson +{ + /// + public UsageGetUsageResponseData FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UsageGetUsageResponseData.FromRawUnchecked(rawData); +} diff --git a/src/Orb/Models/MatrixConfig.cs b/src/Orb/Models/MatrixConfig.cs index 4dd977f1d..511846519 100644 --- a/src/Orb/Models/MatrixConfig.cs +++ b/src/Orb/Models/MatrixConfig.cs @@ -78,8 +78,11 @@ public override void Validate() public MatrixConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixConfig(MatrixConfig matrixConfig) : base(matrixConfig) { } +#pragma warning restore CS8618 public MatrixConfig(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixSubLineItem.cs b/src/Orb/Models/MatrixSubLineItem.cs index e796b970c..b72ba2515 100644 --- a/src/Orb/Models/MatrixSubLineItem.cs +++ b/src/Orb/Models/MatrixSubLineItem.cs @@ -102,8 +102,11 @@ public override void Validate() public MatrixSubLineItem() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixSubLineItem(MatrixSubLineItem matrixSubLineItem) : base(matrixSubLineItem) { } +#pragma warning restore CS8618 public MatrixSubLineItem(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixValue.cs b/src/Orb/Models/MatrixValue.cs index 52953c47f..1fb9a1ce4 100644 --- a/src/Orb/Models/MatrixValue.cs +++ b/src/Orb/Models/MatrixValue.cs @@ -55,8 +55,11 @@ public override void Validate() public MatrixValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixValue(MatrixValue matrixValue) : base(matrixValue) { } +#pragma warning restore CS8618 public MatrixValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MatrixWithAllocationConfig.cs b/src/Orb/Models/MatrixWithAllocationConfig.cs index 8d4887b55..1b8e5b987 100644 --- a/src/Orb/Models/MatrixWithAllocationConfig.cs +++ b/src/Orb/Models/MatrixWithAllocationConfig.cs @@ -96,8 +96,11 @@ public override void Validate() public MatrixWithAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithAllocationConfig(MatrixWithAllocationConfig matrixWithAllocationConfig) : base(matrixWithAllocationConfig) { } +#pragma warning restore CS8618 public MatrixWithAllocationConfig(IReadOnlyDictionary rawData) { @@ -183,10 +186,13 @@ public override void Validate() public MatrixWithAllocationConfigMatrixValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithAllocationConfigMatrixValue( MatrixWithAllocationConfigMatrixValue matrixWithAllocationConfigMatrixValue ) : base(matrixWithAllocationConfigMatrixValue) { } +#pragma warning restore CS8618 public MatrixWithAllocationConfigMatrixValue(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Maximum.cs b/src/Orb/Models/Maximum.cs index f60f5a592..f54c13be3 100644 --- a/src/Orb/Models/Maximum.cs +++ b/src/Orb/Models/Maximum.cs @@ -80,9 +80,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum(Maximum maximum) : base(maximum) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Maximum(IReadOnlyDictionary rawData) @@ -173,8 +176,11 @@ public override void Validate() public MaximumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumFilter(MaximumFilter maximumFilter) : base(maximumFilter) { } +#pragma warning restore CS8618 public MaximumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MaximumInterval.cs b/src/Orb/Models/MaximumInterval.cs index 5b4c83052..d3586e542 100644 --- a/src/Orb/Models/MaximumInterval.cs +++ b/src/Orb/Models/MaximumInterval.cs @@ -108,8 +108,11 @@ public override void Validate() public MaximumInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumInterval(MaximumInterval maximumInterval) : base(maximumInterval) { } +#pragma warning restore CS8618 public MaximumInterval(IReadOnlyDictionary rawData) { @@ -200,8 +203,11 @@ public override void Validate() public MaximumIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaximumIntervalFilter(MaximumIntervalFilter maximumIntervalFilter) : base(maximumIntervalFilter) { } +#pragma warning restore CS8618 public MaximumIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Metrics/BillableMetric.cs b/src/Orb/Models/Metrics/BillableMetric.cs index b0711a9a9..d50aefda7 100644 --- a/src/Orb/Models/Metrics/BillableMetric.cs +++ b/src/Orb/Models/Metrics/BillableMetric.cs @@ -1,6 +1,8 @@ using System.Collections.Frozen; using System.Collections.Generic; +using System.Collections.Immutable; using System.Diagnostics.CodeAnalysis; +using System.Linq; using System.Text.Json; using System.Text.Json.Serialization; using Orb.Core; @@ -85,18 +87,41 @@ public required string Name init { this._rawData.Set("name", value); } } - public required ApiEnum Status + public required ApiEnum Status { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("status"); + return this._rawData.GetNotNullClass>("status"); } init { this._rawData.Set("status", value); } } + public IReadOnlyList>? ParameterDefinitions + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct< + ImmutableArray> + >("parameter_definitions"); + } + init + { + this._rawData.Set>?>( + "parameter_definitions", + value == null + ? null + : ImmutableArray.ToImmutableArray( + Enumerable.Select( + value, + (item) => FrozenDictionary.ToFrozenDictionary(item) + ) + ) + ); + } + } + /// public override void Validate() { @@ -106,12 +131,16 @@ public override void Validate() _ = this.Metadata; _ = this.Name; this.Status.Validate(); + _ = this.ParameterDefinitions; } public BillableMetric() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BillableMetric(BillableMetric billableMetric) : base(billableMetric) { } +#pragma warning restore CS8618 public BillableMetric(IReadOnlyDictionary rawData) { @@ -140,7 +169,7 @@ public BillableMetric FromRawUnchecked(IReadOnlyDictionary BillableMetric.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Metrics.StatusConverter))] +[JsonConverter(typeof(StatusConverter))] public enum Status { Active, @@ -148,9 +177,9 @@ public enum Status Archived, } -sealed class StatusConverter : JsonConverter +sealed class StatusConverter : JsonConverter { - public override global::Orb.Models.Metrics.Status Read( + public override Status Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -158,26 +187,22 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "active" => global::Orb.Models.Metrics.Status.Active, - "draft" => global::Orb.Models.Metrics.Status.Draft, - "archived" => global::Orb.Models.Metrics.Status.Archived, - _ => (global::Orb.Models.Metrics.Status)(-1), + "active" => Status.Active, + "draft" => Status.Draft, + "archived" => Status.Archived, + _ => (Status)(-1), }; } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Metrics.Status value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Status value, JsonSerializerOptions options) { JsonSerializer.Serialize( writer, value switch { - global::Orb.Models.Metrics.Status.Active => "active", - global::Orb.Models.Metrics.Status.Draft => "draft", - global::Orb.Models.Metrics.Status.Archived => "archived", + Status.Active => "active", + Status.Draft => "draft", + Status.Archived => "archived", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), diff --git a/src/Orb/Models/Metrics/MetricCreateParams.cs b/src/Orb/Models/Metrics/MetricCreateParams.cs index 2a7de8902..5b4e2ca53 100644 --- a/src/Orb/Models/Metrics/MetricCreateParams.cs +++ b/src/Orb/Models/Metrics/MetricCreateParams.cs @@ -13,8 +13,12 @@ namespace Orb.Models.Metrics; /// This endpoint is used to create a [metric](/core-concepts###metric) using a SQL /// string. See [SQL support](/extensibility/advanced-metrics#sql-support) for a description /// of constructing SQL queries with examples. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricCreateParams : ParamsBase +public record class MetricCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -99,11 +103,14 @@ public required string Sql public MetricCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricCreateParams(MetricCreateParams metricCreateParams) : base(metricCreateParams) { this._rawBodyData = new(metricCreateParams._rawBodyData); } +#pragma warning restore CS8618 public MetricCreateParams( IReadOnlyDictionary rawHeaderData, @@ -130,7 +137,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static MetricCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -144,6 +151,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/metrics") @@ -169,4 +204,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricFetchParams.cs b/src/Orb/Models/Metrics/MetricFetchParams.cs index 51a02af22..b8ff03a76 100644 --- a/src/Orb/Models/Metrics/MetricFetchParams.cs +++ b/src/Orb/Models/Metrics/MetricFetchParams.cs @@ -11,18 +11,25 @@ namespace Orb.Models.Metrics; /// /// This endpoint is used to list [metrics](/core-concepts#metric). It returns information /// about the metrics including its name, description, and item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricFetchParams : ParamsBase +public record class MetricFetchParams : ParamsBase { public string? MetricID { get; init; } public MetricFetchParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricFetchParams(MetricFetchParams metricFetchParams) : base(metricFetchParams) { this.MetricID = metricFetchParams.MetricID; } +#pragma warning restore CS8618 public MetricFetchParams( IReadOnlyDictionary rawHeaderData, @@ -37,24 +44,56 @@ IReadOnlyDictionary rawQueryData [SetsRequiredMembers] MetricFetchParams( FrozenDictionary rawHeaderData, - FrozenDictionary rawQueryData + FrozenDictionary rawQueryData, + string metricID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); + this.MetricID = metricID; } #pragma warning restore CS8618 - /// + /// public static MetricFetchParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, - IReadOnlyDictionary rawQueryData + IReadOnlyDictionary rawQueryData, + string metricID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), - FrozenDictionary.ToFrozenDictionary(rawQueryData) + FrozenDictionary.ToFrozenDictionary(rawQueryData), + metricID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["MetricID"] = JsonSerializer.SerializeToElement(this.MetricID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(MetricFetchParams? other) + { + if (other == null) + { + return false; + } + return (this.MetricID?.Equals(other.MetricID) ?? other.MetricID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); } public override Uri Url(ClientOptions options) @@ -75,4 +114,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricListPage.cs b/src/Orb/Models/Metrics/MetricListPage.cs index 9cdc0abd1..e6f7cd2b5 100644 --- a/src/Orb/Models/Metrics/MetricListPage.cs +++ b/src/Orb/Models/Metrics/MetricListPage.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Linq; using System.Text.Json; using System.Threading; using System.Threading.Tasks; @@ -63,5 +64,20 @@ public void Validate() } public override string ToString() => - JsonSerializer.Serialize(this.Items, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(JsonSerializer.SerializeToElement(this.Items)), + ModelBase.ToStringSerializerOptions + ); + + public override bool Equals(object? obj) + { + if (obj is not MetricListPage other) + { + return false; + } + + return Enumerable.SequenceEqual(this.Items, other.Items); + } + + public override int GetHashCode() => 0; } diff --git a/src/Orb/Models/Metrics/MetricListPageResponse.cs b/src/Orb/Models/Metrics/MetricListPageResponse.cs index 5e20d729f..2e5d21459 100644 --- a/src/Orb/Models/Metrics/MetricListPageResponse.cs +++ b/src/Orb/Models/Metrics/MetricListPageResponse.cs @@ -49,8 +49,11 @@ public override void Validate() public MetricListPageResponse() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricListPageResponse(MetricListPageResponse metricListPageResponse) : base(metricListPageResponse) { } +#pragma warning restore CS8618 public MetricListPageResponse(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/Metrics/MetricListParams.cs b/src/Orb/Models/Metrics/MetricListParams.cs index 8feb4f9e1..b16a4b570 100644 --- a/src/Orb/Models/Metrics/MetricListParams.cs +++ b/src/Orb/Models/Metrics/MetricListParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Metrics; /// This endpoint is used to fetch [metric](/core-concepts##metric) details given /// a metric identifier. It returns information about the metrics including its name, /// description, and item. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricListParams : ParamsBase +public record class MetricListParams : ParamsBase { public DateTimeOffset? CreatedAtGt { @@ -92,8 +96,11 @@ public long? Limit public MetricListParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricListParams(MetricListParams metricListParams) : base(metricListParams) { } +#pragma warning restore CS8618 public MetricListParams( IReadOnlyDictionary rawHeaderData, @@ -116,7 +123,7 @@ FrozenDictionary rawQueryData } #pragma warning restore CS8618 - /// + /// public static MetricListParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData @@ -128,6 +135,32 @@ IReadOnlyDictionary rawQueryData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(MetricListParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData); + } + public override Uri Url(ClientOptions options) { return new UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/metrics") @@ -144,4 +177,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Metrics/MetricUpdateParams.cs b/src/Orb/Models/Metrics/MetricUpdateParams.cs index 65848c97b..ad85e0537 100644 --- a/src/Orb/Models/Metrics/MetricUpdateParams.cs +++ b/src/Orb/Models/Metrics/MetricUpdateParams.cs @@ -12,8 +12,12 @@ namespace Orb.Models.Metrics; /// /// This endpoint allows you to update the `metadata` property on a metric. If you /// pass `null` for the metadata value, it will clear any existing metadata for that invoice. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class MetricUpdateParams : ParamsBase +public record class MetricUpdateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -48,6 +52,8 @@ public IReadOnlyDictionary RawBodyData public MetricUpdateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MetricUpdateParams(MetricUpdateParams metricUpdateParams) : base(metricUpdateParams) { @@ -55,6 +61,7 @@ public MetricUpdateParams(MetricUpdateParams metricUpdateParams) this._rawBodyData = new(metricUpdateParams._rawBodyData); } +#pragma warning restore CS8618 public MetricUpdateParams( IReadOnlyDictionary rawHeaderData, @@ -72,27 +79,61 @@ IReadOnlyDictionary rawBodyData MetricUpdateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string metricID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.MetricID = metricID; } #pragma warning restore CS8618 - /// + /// public static MetricUpdateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string metricID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + metricID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["MetricID"] = JsonSerializer.SerializeToElement(this.MetricID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(MetricUpdateParams? other) + { + if (other == null) + { + return false; + } + return (this.MetricID?.Equals(other.MetricID) ?? other.MetricID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override Uri Url(ClientOptions options) @@ -122,4 +163,9 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } diff --git a/src/Orb/Models/Minimum.cs b/src/Orb/Models/Minimum.cs index cebe5c9e5..d7a0dd608 100644 --- a/src/Orb/Models/Minimum.cs +++ b/src/Orb/Models/Minimum.cs @@ -80,9 +80,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum(Minimum minimum) : base(minimum) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public Minimum(IReadOnlyDictionary rawData) @@ -173,8 +176,11 @@ public override void Validate() public MinimumFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumFilter(MinimumFilter minimumFilter) : base(minimumFilter) { } +#pragma warning restore CS8618 public MinimumFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MinimumInterval.cs b/src/Orb/Models/MinimumInterval.cs index 3cb6c2846..b8a135599 100644 --- a/src/Orb/Models/MinimumInterval.cs +++ b/src/Orb/Models/MinimumInterval.cs @@ -108,8 +108,11 @@ public override void Validate() public MinimumInterval() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumInterval(MinimumInterval minimumInterval) : base(minimumInterval) { } +#pragma warning restore CS8618 public MinimumInterval(IReadOnlyDictionary rawData) { @@ -200,8 +203,11 @@ public override void Validate() public MinimumIntervalFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MinimumIntervalFilter(MinimumIntervalFilter minimumIntervalFilter) : base(minimumIntervalFilter) { } +#pragma warning restore CS8618 public MinimumIntervalFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs b/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs index fb559b896..51a4f9bba 100644 --- a/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryAmountDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment( MonetaryAmountDiscountAdjustment monetaryAmountDiscountAdjustment ) : base(monetaryAmountDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryAmountDiscountAdjustment(IReadOnlyDictionary rawData) @@ -315,10 +318,13 @@ public override void Validate() public MonetaryAmountDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryAmountDiscountAdjustmentFilter( MonetaryAmountDiscountAdjustmentFilter monetaryAmountDiscountAdjustmentFilter ) : base(monetaryAmountDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryAmountDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryMaximumAdjustment.cs b/src/Orb/Models/MonetaryMaximumAdjustment.cs index 731f2bb04..270213cde 100644 --- a/src/Orb/Models/MonetaryMaximumAdjustment.cs +++ b/src/Orb/Models/MonetaryMaximumAdjustment.cs @@ -166,9 +166,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment(MonetaryMaximumAdjustment monetaryMaximumAdjustment) : base(monetaryMaximumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMaximumAdjustment(IReadOnlyDictionary rawData) @@ -311,10 +314,13 @@ public override void Validate() public MonetaryMaximumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryMaximumAdjustmentFilter( MonetaryMaximumAdjustmentFilter monetaryMaximumAdjustmentFilter ) : base(monetaryMaximumAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryMaximumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryMinimumAdjustment.cs b/src/Orb/Models/MonetaryMinimumAdjustment.cs index 1c034f6fe..b3d0cd96f 100644 --- a/src/Orb/Models/MonetaryMinimumAdjustment.cs +++ b/src/Orb/Models/MonetaryMinimumAdjustment.cs @@ -180,9 +180,12 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment(MonetaryMinimumAdjustment monetaryMinimumAdjustment) : base(monetaryMinimumAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryMinimumAdjustment(IReadOnlyDictionary rawData) @@ -325,10 +328,13 @@ public override void Validate() public MonetaryMinimumAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryMinimumAdjustmentFilter( MonetaryMinimumAdjustmentFilter monetaryMinimumAdjustmentFilter ) : base(monetaryMinimumAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryMinimumAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs b/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs index 129c3b351..ea6e1fe3a 100644 --- a/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryPercentageDiscountAdjustment.cs @@ -172,11 +172,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment( MonetaryPercentageDiscountAdjustment monetaryPercentageDiscountAdjustment ) : base(monetaryPercentageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryPercentageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -322,10 +325,13 @@ public override void Validate() public MonetaryPercentageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryPercentageDiscountAdjustmentFilter( MonetaryPercentageDiscountAdjustmentFilter monetaryPercentageDiscountAdjustmentFilter ) : base(monetaryPercentageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryPercentageDiscountAdjustmentFilter( IReadOnlyDictionary rawData diff --git a/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs b/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs index 77fe60fab..d59830656 100644 --- a/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs +++ b/src/Orb/Models/MonetaryUsageDiscountAdjustment.cs @@ -169,11 +169,14 @@ public override void Validate() [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment( MonetaryUsageDiscountAdjustment monetaryUsageDiscountAdjustment ) : base(monetaryUsageDiscountAdjustment) { } +#pragma warning restore CS8618 [System::Obsolete("Required properties are deprecated: applies_to_price_ids")] public MonetaryUsageDiscountAdjustment(IReadOnlyDictionary rawData) @@ -316,10 +319,13 @@ public override void Validate() public MonetaryUsageDiscountAdjustmentFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MonetaryUsageDiscountAdjustmentFilter( MonetaryUsageDiscountAdjustmentFilter monetaryUsageDiscountAdjustmentFilter ) : base(monetaryUsageDiscountAdjustmentFilter) { } +#pragma warning restore CS8618 public MonetaryUsageDiscountAdjustmentFilter(IReadOnlyDictionary rawData) { diff --git a/src/Orb/Models/NewAllocationPrice.cs b/src/Orb/Models/NewAllocationPrice.cs index c39dcb00a..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..ecd09a81d 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,4551 @@ 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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(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); - - 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); + /// + /// Returns true and sets the 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(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, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); + /// + /// Returns true and sets the 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) => {...}, + /// (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 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 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) => {...}, + /// (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 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), + 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(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(), + (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, + TieredWithProration _ => 14, + NewPlanUnitWithProrationPrice _ => 15, + NewPlanGroupedAllocationPrice _ => 16, + NewPlanBulkWithProrationPrice _ => 17, + NewPlanGroupedWithProratedMinimumPrice _ => 18, + NewPlanGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewPlanMatrixWithDisplayNamePrice _ => 21, + NewPlanGroupedTieredPackagePrice _ => 22, + NewPlanMaxGroupTieredPackagePrice _ => 23, + NewPlanScalableMatrixWithUnitPricingPrice _ => 24, + NewPlanScalableMatrixWithTieredPricingPrice _ => 25, + NewPlanCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + NewPlanMinimumCompositePrice _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -1, + }; + } +} + +sealed class PricePriceConverter : JsonConverter +{ + public override PricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } + + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_allocation": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_proration": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_prorated_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_metered_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_with_min_max_thresholds": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_display_name": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered_package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "max_group_tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "scalable_matrix_with_unit_pricing": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + 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 (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 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)); + } +} - 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 - } +class BulkWithFiltersFromRaw : IFromRawJson +{ + /// + public BulkWithFilters FromRawUnchecked(IReadOnlyDictionary rawData) => + BulkWithFilters.FromRawUnchecked(rawData); +} - return new(element); - } - case "bulk_with_filters": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } +/// +/// 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) + ); + } + } - 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 - } + /// + /// 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 "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + public 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); } + } - return new(element); - } - case "threshold_total_amount": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// The 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 "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.UnitAmount; + _ = this.TierLowerBound; + } - 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 Tier() { } - 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 Tier(Tier tier) + : base(tier) { } +#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 Tier(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] + Tier(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 Tier 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 - } + [SetsRequiredMembers] + public Tier(string unitAmount) + : this() + { + this.UnitAmount = unitAmount; + } +} - 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 TierFromRaw : IFromRawJson +{ + /// + public Tier FromRawUnchecked(IReadOnlyDictionary rawData) => + Tier.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 - } +/// +/// 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), + }; + } - return new(element); - } - case "grouped_allocation": + public override void Write( + Utf8JsonWriter writer, + BulkWithFiltersCadence 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 - } + 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 + ); + } +} - 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(BulkWithFiltersConversionRateConfigConverter))] +public record class BulkWithFiltersConversionRateConfig : 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; - 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 JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - 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 BulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "matrix_with_display_name": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public 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" + ), + }; + } - 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 BulkWithFiltersConversionRateConfig( + 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 BulkWithFiltersConversionRateConfig( + 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 BulkWithFiltersConversionRateConfig" + ); + } + 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(BulkWithFiltersConversionRateConfig? 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 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( + var deserialized = 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 +4957,33 @@ JsonSerializerOptions options } default: { - return new PricePrice(element); + return new BulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PricePrice? value, + BulkWithFiltersConversionRateConfig 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 +5026,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 +5103,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 +5199,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5250,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 +5274,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 +5314,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 +5413,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); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - Tier(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public Tier(string unitAmount) - : this() - { - this.UnitAmount = unitAmount; - } -} - -class TierFromRaw : IFromRawJson -{ - /// - public global::Orb.Models.Plans.Tier FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.Tier.FromRawUnchecked(rawData); -} - -/// -/// The cadence to bill for this price on. -/// -[JsonConverter(typeof(global::Orb.Models.Plans.CadenceConverter))] -public enum Cadence -{ - Annual, - SemiAnnual, - Monthly, - Quarterly, - OneTime, - Custom, -} - -sealed class CadenceConverter : JsonConverter -{ - public override global::Orb.Models.Plans.Cadence Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options + public TieredWithProrationConfigTier() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfigTier( + TieredWithProrationConfigTier tieredWithProrationConfigTier ) + : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 + + public TieredWithProrationConfigTier(IReadOnlyDictionary 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); } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Plans.Cadence value, - JsonSerializerOptions options +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationConfigTier(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + 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 +5563,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 +5590,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 +5611,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5631,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5642,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3854,7 +5663,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 +5672,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5683,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3890,16 +5699,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 +5727,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 +5744,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 +5792,10 @@ JsonSerializerOptions 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 +5812,10 @@ JsonSerializerOptions 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 +5824,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 +5840,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 +5913,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 +5972,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 +6068,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6120,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 +6143,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 +6183,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 +6205,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 +6216,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 +6236,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 +6252,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 +6355,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 +6381,7 @@ public JsonElement Json } } - public TieredWithProrationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -4616,7 +6390,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig( + public GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -4625,7 +6399,7 @@ public TieredWithProrationConversionRateConfig( this._element = element; } - public TieredWithProrationConversionRateConfig(JsonElement element) + public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -4634,7 +6408,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 +6429,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6449,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6460,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4707,7 +6481,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 +6490,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6501,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4743,16 +6517,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 +6545,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 +6562,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 +6610,10 @@ JsonSerializerOptions 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 +6630,10 @@ JsonSerializerOptions 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 +6642,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 +6658,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 +6790,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 +6886,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6938,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 +6961,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 +7001,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 +7023,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 +7034,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 +7054,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 +7070,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 +7173,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 +7199,7 @@ public JsonElement Json } } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5423,7 +7208,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig( + public CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5432,7 +7217,7 @@ public GroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public GroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -5441,7 +7226,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 +7247,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7267,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7278,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5514,7 +7299,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 +7308,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7319,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5550,16 +7335,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 +7363,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 +7380,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 +7428,10 @@ JsonSerializerOptions 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 +7448,10 @@ JsonSerializerOptions 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 +7460,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 +7475,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 +7606,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 +7702,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7754,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 +7777,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 +7817,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 +7839,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 +7849,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 +7869,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 +7885,171 @@ 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); } } /// - /// 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); } + } + + /// + /// 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>("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))] +public sealed record class MatrixValue : JsonModel +{ /// - /// The event property used to group usage before applying allocations + /// 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 GroupingKey + public required IReadOnlyList DimensionValues { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("grouping_key"); + return this._rawData.GetNotNullStruct>("dimension_values"); + } + init + { + 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,54 +8064,47 @@ public required string UnitAmount /// public override void Validate() { - _ = this.CumulativeAllocation; - _ = this.GroupAllocation; - _ = this.GroupingKey; + _ = this.DimensionValues; _ = this.UnitAmount; } - public CumulativeGroupedAllocationConfig() { } + public MatrixValue() { } - public CumulativeGroupedAllocationConfig( - global::Orb.Models.Plans.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig - ) - : base(cumulativeGroupedAllocationConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixValue(MatrixValue matrixValue) + : base(matrixValue) { } +#pragma warning restore CS8618 - public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) + public MatrixValue(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - CumulativeGroupedAllocationConfig(FrozenDictionary rawData) + MatrixValue(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class MatrixValueFromRaw : IFromRawJson { /// - public global::Orb.Models.Plans.CumulativeGroupedAllocationConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Plans.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.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 +8121,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6230,7 +8130,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6239,7 +8139,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6248,7 +8148,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 +8169,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8189,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8200,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6321,7 +8221,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 +8230,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8241,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6357,16 +8257,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 +8285,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 +8302,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 +8350,10 @@ JsonSerializerOptions 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 +8370,10 @@ JsonSerializerOptions 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 +8382,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 +8397,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 +8429,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 +8528,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 +8624,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8677,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 +8699,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 +8739,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 +8760,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 +8770,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 +8790,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 +8806,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 +8906,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 +8977,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7003,7 +8986,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7012,7 +8995,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -7021,7 +9004,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 +9025,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9045,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9056,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7094,7 +9077,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 +9086,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9097,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7130,16 +9113,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 +9141,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 +9158,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 +9206,10 @@ JsonSerializerOptions 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 +9226,10 @@ JsonSerializerOptions 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 +9238,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 +9253,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 +9311,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 +9380,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 +9476,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9546,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7558,8 +9556,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 +9577,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 +9605,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 +9615,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 +9635,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 +9653,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 +9677,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 +9696,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 +9710,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 +9762,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 +9783,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9803,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9814,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7851,7 +9844,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9855,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7883,11 +9876,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 +9905,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 +9916,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 +9963,10 @@ JsonSerializerOptions 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 +9983,10 @@ JsonSerializerOptions 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 +9995,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 +10010,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 +10029,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 +10137,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 +10233,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10308,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -8312,8 +10318,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 +10339,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 +10367,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 +10377,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 +10397,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 +10415,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 +10470,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 +10489,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 +10505,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 +10557,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 +10578,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10598,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10609,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8637,7 +10639,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10650,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8669,11 +10671,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 +10700,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 +10711,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 +10759,10 @@ JsonSerializerOptions 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 +10779,10 @@ JsonSerializerOptions 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 +10791,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 +10806,7 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class Adjustment : JsonModel { /// @@ -8833,8 +10844,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 +10864,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 +10877,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 +10972,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 +10993,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 +11014,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 +11035,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 +11056,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 +11076,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 +11087,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 +11132,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11143,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 +11210,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 +11221,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 +11271,10 @@ JsonSerializerOptions 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 +11291,10 @@ JsonSerializerOptions 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 +11311,10 @@ JsonSerializerOptions 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 +11328,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 +11345,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 +11415,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 +11436,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 +11476,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 +11486,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 +11496,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 +11515,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 +11533,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 +11550,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..a21c7206d 100644 --- a/src/Orb/Models/Price.cs +++ b/src/Orb/Models/Price.cs @@ -72,7 +72,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 @@ -113,7 +114,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 @@ -154,7 +156,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 @@ -195,7 +198,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 @@ -236,7 +240,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 @@ -277,7 +282,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 @@ -318,7 +324,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 @@ -359,7 +366,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 @@ -400,7 +408,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 @@ -441,7 +450,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 +459,48 @@ 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, + 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 @@ -482,7 +534,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 @@ -523,7 +576,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 @@ -564,7 +618,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 @@ -605,7 +660,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 @@ -646,7 +702,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 @@ -687,7 +744,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 @@ -728,7 +786,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 @@ -769,7 +828,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 @@ -810,7 +870,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 @@ -851,7 +912,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 @@ -892,7 +954,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 @@ -1068,7 +1131,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 +1170,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 +1191,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 +1212,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 +1233,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 +1254,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 +1275,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 +1296,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 +1317,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 +1338,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 +1359,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 +1380,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 +1403,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 +1424,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 +1445,7 @@ public bool TryPickUnitWithPercent([NotNullWhen(true)] out UnitWithPercent? valu /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1397,7 +1466,7 @@ public bool TryPickMatrixWithAllocation([NotNullWhen(true)] out MatrixWithAlloca /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1418,7 +1487,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 +1508,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 +1529,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 +1550,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 +1573,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 +1596,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 +1619,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 +1640,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 +1661,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 +1682,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 +1705,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 +1728,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 +1749,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 +1770,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 +1814,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 +1835,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 +1856,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 +1876,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 +1887,39 @@ public bool TryPickEventOutput([NotNullWhen(true)] out EventOutput? value) /// /// /// instance.Switch( - /// (Unit value) => {...}, - /// (Tiered value) => {...}, - /// (Bulk value) => {...}, - /// (BulkWithFilters value) => {...}, - /// (Package value) => {...}, - /// (Matrix value) => {...}, - /// (ThresholdTotalAmount value) => {...}, - /// (TieredPackage value) => {...}, - /// (TieredWithMinimum value) => {...}, - /// (GroupedTiered value) => {...}, - /// (TieredPackageWithMinimum value) => {...}, - /// (PackageWithAllocation value) => {...}, - /// (UnitWithPercent value) => {...}, - /// (MatrixWithAllocation value) => {...}, - /// (TieredWithProration value) => {...}, - /// (UnitWithProration value) => {...}, - /// (GroupedAllocation value) => {...}, - /// (BulkWithProration value) => {...}, - /// (GroupedWithProratedMinimum value) => {...}, - /// (GroupedWithMeteredMinimum value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, - /// (MatrixWithDisplayName value) => {...}, - /// (GroupedTieredPackage value) => {...}, - /// (MaxGroupTieredPackage value) => {...}, - /// (ScalableMatrixWithUnitPricing value) => {...}, - /// (ScalableMatrixWithTieredPricing value) => {...}, - /// (CumulativeGroupedBulk value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, - /// (MinimumComposite value) => {...}, - /// (Percent value) => {...}, - /// (EventOutput value) => {...} + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, + /// (TieredWithProration value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1862,7 +1953,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 @@ -1954,8 +2046,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 +2070,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +2081,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Unit value) => {...}, - /// (Tiered value) => {...}, - /// (Bulk value) => {...}, - /// (BulkWithFilters value) => {...}, - /// (Package value) => {...}, - /// (Matrix value) => {...}, - /// (ThresholdTotalAmount value) => {...}, - /// (TieredPackage value) => {...}, - /// (TieredWithMinimum value) => {...}, - /// (GroupedTiered value) => {...}, - /// (TieredPackageWithMinimum value) => {...}, - /// (PackageWithAllocation value) => {...}, - /// (UnitWithPercent value) => {...}, - /// (MatrixWithAllocation value) => {...}, - /// (TieredWithProration value) => {...}, - /// (UnitWithProration value) => {...}, - /// (GroupedAllocation value) => {...}, - /// (BulkWithProration value) => {...}, - /// (GroupedWithProratedMinimum value) => {...}, - /// (GroupedWithMeteredMinimum value) => {...}, - /// (GroupedWithMinMaxThresholds value) => {...}, - /// (MatrixWithDisplayName value) => {...}, - /// (GroupedTieredPackage value) => {...}, - /// (MaxGroupTieredPackage value) => {...}, - /// (ScalableMatrixWithUnitPricing value) => {...}, - /// (ScalableMatrixWithTieredPricing value) => {...}, - /// (CumulativeGroupedBulk value) => {...}, - /// (CumulativeGroupedAllocation value) => {...}, - /// (PriceMinimum value) => {...}, - /// (MinimumComposite value) => {...}, - /// (Percent value) => {...}, - /// (EventOutput value) => {...} + /// (Unit value) => {...}, + /// (Tiered value) => {...}, + /// (Bulk value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (Package value) => {...}, + /// (Matrix value) => {...}, + /// (ThresholdTotalAmount value) => {...}, + /// (TieredPackage value) => {...}, + /// (TieredWithMinimum value) => {...}, + /// (GroupedTiered value) => {...}, + /// (TieredPackageWithMinimum value) => {...}, + /// (PackageWithAllocation value) => {...}, + /// (UnitWithPercent value) => {...}, + /// (MatrixWithAllocation value) => {...}, + /// (TieredWithProration value) => {...}, + /// (UnitWithProration value) => {...}, + /// (GroupedAllocation value) => {...}, + /// (BulkWithProration value) => {...}, + /// (GroupedWithProratedMinimum value) => {...}, + /// (GroupedWithMeteredMinimum value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (MatrixWithDisplayName value) => {...}, + /// (GroupedTieredPackage value) => {...}, + /// (MaxGroupTieredPackage value) => {...}, + /// (ScalableMatrixWithUnitPricing value) => {...}, + /// (ScalableMatrixWithTieredPricing value) => {...}, + /// (CumulativeGroupedBulk value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (MinimumComposite value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -2051,7 +2147,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 @@ -2087,7 +2184,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), @@ -2151,7 +2249,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); @@ -2204,17 +2304,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 +2323,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Unit _ => 0, + Tiered _ => 1, + Bulk _ => 2, + BulkWithFilters _ => 3, + Package _ => 4, + Matrix _ => 5, + ThresholdTotalAmount _ => 6, + TieredPackage _ => 7, + TieredWithMinimum _ => 8, + GroupedTiered _ => 9, + TieredPackageWithMinimum _ => 10, + PackageWithAllocation _ => 11, + UnitWithPercent _ => 12, + MatrixWithAllocation _ => 13, + TieredWithProration _ => 14, + UnitWithProration _ => 15, + GroupedAllocation _ => 16, + BulkWithProration _ => 17, + GroupedWithProratedMinimum _ => 18, + GroupedWithMeteredMinimum _ => 19, + GroupedWithMinMaxThresholds _ => 20, + MatrixWithDisplayName _ => 21, + GroupedTieredPackage _ => 22, + MaxGroupTieredPackage _ => 23, + ScalableMatrixWithUnitPricing _ => 24, + ScalableMatrixWithTieredPricing _ => 25, + CumulativeGroupedBulk _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + MinimumComposite _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -1, + }; + } } sealed class PriceConverter : JsonConverter @@ -2253,12 +2398,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2272,12 +2415,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 +2432,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 +2452,10 @@ JsonSerializerOptions 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 +2469,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 +2486,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 +2506,10 @@ JsonSerializerOptions 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 +2523,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 +2543,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2433,12 +2560,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 +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 } @@ -2477,12 +2600,10 @@ JsonSerializerOptions 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 +2620,10 @@ JsonSerializerOptions 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 +2640,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2543,12 +2660,10 @@ JsonSerializerOptions 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 +2680,10 @@ JsonSerializerOptions 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 +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 } @@ -2609,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 } @@ -2631,12 +2740,10 @@ JsonSerializerOptions 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 +2760,10 @@ JsonSerializerOptions 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 +2780,10 @@ JsonSerializerOptions 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 +2800,10 @@ JsonSerializerOptions 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 +2820,10 @@ JsonSerializerOptions 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 +2840,10 @@ JsonSerializerOptions 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 +2860,10 @@ JsonSerializerOptions 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 +2880,10 @@ JsonSerializerOptions 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 +2900,10 @@ JsonSerializerOptions 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 +2920,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 "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(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 } @@ -2870,12 +2980,10 @@ JsonSerializerOptions 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 +2997,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 +3014,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 +3193,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 +3376,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 +3411,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 +3429,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -3309,11 +3440,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 +3646,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 +3830,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 +3851,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +3871,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +3882,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3775,7 +3912,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +3923,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3836,10 +3973,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 +3984,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +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 } @@ -3903,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 } @@ -3979,6 +4125,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 +4374,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 +4557,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 +4592,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 +4610,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -4357,11 +4621,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 +4829,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 +5015,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 +5036,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5056,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5067,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4827,7 +5097,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5108,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4888,10 +5158,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 +5169,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5216,10 @@ JsonSerializerOptions 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 +5236,10 @@ JsonSerializerOptions 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 +5310,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 +5572,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 +5742,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 +5778,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 +5795,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -5407,11 +5806,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 +6014,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 +6199,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 +6220,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6240,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6251,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5876,7 +6281,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6292,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5937,10 +6342,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 +6353,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +6400,10 @@ JsonSerializerOptions 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 +6420,10 @@ JsonSerializerOptions 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 +6494,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 +6758,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 +6930,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 +6966,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 +6988,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -6467,11 +6999,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 +7150,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 +7229,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 +7308,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 +7474,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 +7662,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 +7683,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7703,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7714,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7197,7 +7744,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7755,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7258,10 +7805,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 +7816,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +7864,10 @@ JsonSerializerOptions 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 +7884,10 @@ JsonSerializerOptions 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 +7958,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 +8212,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 +8395,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 +8430,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 +8448,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -7780,11 +8459,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 +8667,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 +8853,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 +8874,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8894,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8905,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8250,7 +8935,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8946,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8311,10 +8996,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 +9007,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9054,10 @@ JsonSerializerOptions 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 +9074,10 @@ JsonSerializerOptions 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 +9148,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 +9399,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 +9582,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 +9617,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 +9635,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -8832,11 +9646,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 +9854,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 +10040,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 +10061,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10081,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10092,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9302,7 +10122,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10133,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9363,10 +10183,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 +10194,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10241,10 @@ JsonSerializerOptions 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 +10261,10 @@ JsonSerializerOptions 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 +10335,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 +10588,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 +10775,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 +10810,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 +10833,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ThresholdTotalAmountConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -9895,11 +10844,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 +11059,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 +11250,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 +11271,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +11291,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +11302,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10377,7 +11332,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11343,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10438,10 +11393,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 +11404,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +11452,10 @@ JsonSerializerOptions 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 +11472,10 @@ JsonSerializerOptions 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 +11603,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 +11697,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 +11740,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 +11999,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 +12186,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 +12221,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 +12244,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -11157,11 +12255,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 +12466,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 +12654,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 +12675,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +12695,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +12706,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11632,7 +12736,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +12747,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -11693,10 +12797,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 +12808,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +12856,10 @@ JsonSerializerOptions 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 +12876,10 @@ JsonSerializerOptions 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 +13007,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 +13088,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 +13127,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 +13383,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 +13570,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 +13605,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 +13628,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -12397,11 +13639,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 +13852,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 +14041,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 +14062,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +14082,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +14093,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12875,7 +14123,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +14134,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -12936,10 +14184,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 +14195,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +14243,10 @@ JsonSerializerOptions 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 +14263,10 @@ JsonSerializerOptions 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 +14425,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 +14529,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 +14570,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 +14839,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 +15011,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 +15047,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 +15069,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -13694,11 +15080,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 +15291,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 +15479,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 +15500,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +15520,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +15531,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14169,7 +15561,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +15572,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14230,10 +15622,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 +15633,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +15681,10 @@ JsonSerializerOptions 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 +15701,10 @@ JsonSerializerOptions 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 +15785,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 +15866,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 +15952,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 +16210,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 +16397,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 +16434,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 +16457,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredPackageWithMinimumConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -14936,11 +16468,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 +16684,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 +16876,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 +16897,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +16917,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +16928,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15420,7 +16958,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +16969,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15481,10 +17019,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 +17030,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +17078,10 @@ JsonSerializerOptions 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 +17098,10 @@ JsonSerializerOptions 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 +17227,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 +17321,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 +17364,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 +17625,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 +17812,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 +17847,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 +17870,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -16200,11 +17881,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 +18096,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 +18287,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 +18308,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18328,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18339,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16682,7 +18369,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18380,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16743,10 +18430,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 +18441,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +18489,10 @@ JsonSerializerOptions 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 +18509,10 @@ JsonSerializerOptions 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 +18587,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 +18675,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 +18936,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 +19123,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 +19158,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 +19181,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithPercentConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -17365,11 +19192,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 +19403,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 +19591,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 +19612,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +19632,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +19643,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17840,7 +19673,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +19684,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17901,10 +19734,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 +19745,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +19793,10 @@ JsonSerializerOptions 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 +19813,10 @@ JsonSerializerOptions 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 +19933,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 +19972,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 +20228,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 +20415,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 +20450,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 +20473,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -18516,11 +20484,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 +20699,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 +20890,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 +20911,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +20931,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +20942,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18998,7 +20972,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +20983,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19059,10 +21033,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 +21044,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +21092,10 @@ JsonSerializerOptions 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 +21112,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -19203,6 +21186,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithAllocationLicenseType, + MatrixWithAllocationLicenseTypeFromRaw + >) +)] +public sealed record class MatrixWithAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MatrixWithAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithAllocationLicenseType( + MatrixWithAllocationLicenseType matrixWithAllocationLicenseType + ) + : base(matrixWithAllocationLicenseType) { } +#pragma warning restore CS8618 + + public MatrixWithAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithAllocationLicenseTypeFromRaw : IFromRawJson +{ + /// + public MatrixWithAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { @@ -19363,6 +21447,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 @@ -19540,6 +21634,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() { @@ -19560,6 +21669,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -19582,6 +21692,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.TieredWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -19592,11 +21703,14 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -19802,10 +21916,13 @@ public override void Validate() public TieredWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationCompositePriceFilter( TieredWithProrationCompositePriceFilter tieredWithProrationCompositePriceFilter ) : base(tieredWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public TieredWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -19988,7 +22105,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 +22126,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +22146,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +22157,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20070,7 +22187,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +22198,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20131,10 +22248,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(TieredWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -20142,7 +22259,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter @@ -20177,12 +22307,10 @@ JsonSerializerOptions 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 +22327,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -20319,10 +22445,13 @@ public override void Validate() public TieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationTieredWithProrationConfig( TieredWithProrationTieredWithProrationConfig tieredWithProrationTieredWithProrationConfig ) : base(tieredWithProrationTieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -20412,10 +22541,13 @@ public override void Validate() public TieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationTieredWithProrationConfigTier( TieredWithProrationTieredWithProrationConfigTier tieredWithProrationTieredWithProrationConfigTier ) : base(tieredWithProrationTieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -20450,6 +22582,107 @@ IReadOnlyDictionary rawData ) => TieredWithProrationTieredWithProrationConfigTier.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + TieredWithProrationLicenseType, + TieredWithProrationLicenseTypeFromRaw + >) +)] +public sealed record class TieredWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public TieredWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationLicenseType( + TieredWithProrationLicenseType tieredWithProrationLicenseType + ) + : base(tieredWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public TieredWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + TieredWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static TieredWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class TieredWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public TieredWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => TieredWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class UnitWithProration : JsonModel { @@ -20610,6 +22843,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 @@ -20787,6 +23030,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() { @@ -20807,6 +23065,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -20829,6 +23088,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.UnitWithProrationConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -20839,11 +23099,14 @@ public UnitWithProration() this.ModelType = JsonSerializer.SerializeToElement("unit_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public UnitWithProration(UnitWithProration unitWithProration) : base(unitWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -21049,10 +23312,13 @@ public override void Validate() public UnitWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationCompositePriceFilter( UnitWithProrationCompositePriceFilter unitWithProrationCompositePriceFilter ) : base(unitWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public UnitWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -21235,7 +23501,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 +23522,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +23542,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +23553,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21317,7 +23583,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +23594,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -21378,10 +23644,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(UnitWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(UnitWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -21389,7 +23655,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class UnitWithProrationConversionRateConfigConverter @@ -21424,12 +23703,10 @@ JsonSerializerOptions 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 +23723,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -21554,10 +23829,13 @@ public override void Validate() public UnitWithProrationUnitWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public UnitWithProrationUnitWithProrationConfig( UnitWithProrationUnitWithProrationConfig unitWithProrationUnitWithProrationConfig ) : base(unitWithProrationUnitWithProrationConfig) { } +#pragma warning restore CS8618 public UnitWithProrationUnitWithProrationConfig( IReadOnlyDictionary rawData @@ -21599,6 +23877,102 @@ IReadOnlyDictionary rawData ) => UnitWithProrationUnitWithProrationConfig.FromRawUnchecked(rawData); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class UnitWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public UnitWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public UnitWithProrationLicenseType(UnitWithProrationLicenseType unitWithProrationLicenseType) + : base(unitWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public UnitWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + UnitWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static UnitWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class UnitWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public UnitWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => UnitWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedAllocation : JsonModel { @@ -21774,6 +24148,16 @@ public required GroupedAllocationGroupedAllocationConfig GroupedAllocationConfig 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 @@ -21936,6 +24320,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() { @@ -21957,6 +24356,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedAllocationConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -21978,6 +24378,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -21988,11 +24389,14 @@ public GroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedAllocation(GroupedAllocation groupedAllocation) : base(groupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -22198,10 +24602,13 @@ public override void Validate() public GroupedAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationCompositePriceFilter( GroupedAllocationCompositePriceFilter groupedAllocationCompositePriceFilter ) : base(groupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedAllocationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -22384,7 +24791,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 +24812,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +24832,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +24843,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22466,7 +24873,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +24884,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -22527,10 +24934,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -22538,7 +24945,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedAllocationConversionRateConfigConverter @@ -22573,12 +24993,10 @@ JsonSerializerOptions 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 +25013,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -22684,10 +25100,13 @@ public override void Validate() public GroupedAllocationGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedAllocationGroupedAllocationConfig( GroupedAllocationGroupedAllocationConfig groupedAllocationGroupedAllocationConfig ) : base(groupedAllocationGroupedAllocationConfig) { } +#pragma warning restore CS8618 public GroupedAllocationGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -22769,6 +25188,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class GroupedAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedAllocationLicenseType(GroupedAllocationLicenseType groupedAllocationLicenseType) + : base(groupedAllocationLicenseType) { } +#pragma warning restore CS8618 + + public GroupedAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedAllocationLicenseTypeFromRaw : IFromRawJson +{ + /// + public GroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedAllocationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class BulkWithProration : JsonModel { @@ -22944,6 +25459,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 @@ -23106,6 +25631,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public BulkWithProrationLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -23127,6 +25667,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -23148,6 +25689,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -23158,11 +25700,14 @@ public BulkWithProration() this.ModelType = JsonSerializer.SerializeToElement("bulk_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public BulkWithProration(BulkWithProration bulkWithProration) : base(bulkWithProration) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -23288,10 +25833,13 @@ public override void Validate() public BulkWithProrationBulkWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationBulkWithProrationConfig( BulkWithProrationBulkWithProrationConfig bulkWithProrationBulkWithProrationConfig ) : base(bulkWithProrationBulkWithProrationConfig) { } +#pragma warning restore CS8618 public BulkWithProrationBulkWithProrationConfig( IReadOnlyDictionary rawData @@ -23381,10 +25929,13 @@ public override void Validate() public BulkWithProrationBulkWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationBulkWithProrationConfigTier( BulkWithProrationBulkWithProrationConfigTier bulkWithProrationBulkWithProrationConfigTier ) : base(bulkWithProrationBulkWithProrationConfigTier) { } +#pragma warning restore CS8618 public BulkWithProrationBulkWithProrationConfigTier( IReadOnlyDictionary rawData @@ -23549,10 +26100,13 @@ public override void Validate() public BulkWithProrationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public BulkWithProrationCompositePriceFilter( BulkWithProrationCompositePriceFilter bulkWithProrationCompositePriceFilter ) : base(bulkWithProrationCompositePriceFilter) { } +#pragma warning restore CS8618 public BulkWithProrationCompositePriceFilter(IReadOnlyDictionary rawData) { @@ -23735,7 +26289,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 +26310,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +26330,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +26341,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23817,7 +26371,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +26382,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -23878,10 +26432,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(BulkWithProrationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(BulkWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -23889,7 +26443,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class BulkWithProrationConversionRateConfigConverter @@ -23924,12 +26491,10 @@ JsonSerializerOptions 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 +26511,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -24022,6 +26585,102 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class BulkWithProrationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public BulkWithProrationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public BulkWithProrationLicenseType(BulkWithProrationLicenseType bulkWithProrationLicenseType) + : base(bulkWithProrationLicenseType) { } +#pragma warning restore CS8618 + + public BulkWithProrationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + BulkWithProrationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static BulkWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class BulkWithProrationLicenseTypeFromRaw : IFromRawJson +{ + /// + public BulkWithProrationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => BulkWithProrationLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -24199,6 +26858,16 @@ public required GroupedWithProratedMinimumGroupedWithProratedMinimumConfig Group 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 @@ -24361,6 +27030,23 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public GroupedWithProratedMinimumLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "license_type" + ); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -24382,6 +27068,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedWithProratedMinimumConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -24403,6 +27090,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -24413,11 +27101,14 @@ public GroupedWithProratedMinimum() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_prorated_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithProratedMinimum(GroupedWithProratedMinimum groupedWithProratedMinimum) : base(groupedWithProratedMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -24626,10 +27317,13 @@ public override void Validate() public GroupedWithProratedMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumCompositePriceFilter( GroupedWithProratedMinimumCompositePriceFilter groupedWithProratedMinimumCompositePriceFilter ) : base(groupedWithProratedMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumCompositePriceFilter( IReadOnlyDictionary rawData @@ -24815,7 +27509,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 +27530,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +27550,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +27561,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24897,7 +27591,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +27602,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -24958,10 +27652,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithProratedMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -24969,7 +27663,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithProratedMinimumConversionRateConfigConverter @@ -25004,12 +27711,10 @@ JsonSerializerOptions 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 +27731,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -25115,10 +27818,13 @@ public override void Validate() public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( GroupedWithProratedMinimumGroupedWithProratedMinimumConfig groupedWithProratedMinimumGroupedWithProratedMinimumConfig ) : base(groupedWithProratedMinimumGroupedWithProratedMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithProratedMinimumGroupedWithProratedMinimumConfig( IReadOnlyDictionary rawData @@ -25203,6 +27909,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithProratedMinimumLicenseType, + GroupedWithProratedMinimumLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithProratedMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithProratedMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithProratedMinimumLicenseType( + GroupedWithProratedMinimumLicenseType groupedWithProratedMinimumLicenseType + ) + : base(groupedWithProratedMinimumLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithProratedMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithProratedMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithProratedMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithProratedMinimumLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithProratedMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithProratedMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -25380,6 +28188,16 @@ public required GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig Grouped 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 { get @@ -25542,6 +28360,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() { @@ -25563,6 +28398,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedWithMeteredMinimumConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -25584,6 +28420,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -25594,11 +28431,14 @@ public GroupedWithMeteredMinimum() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_metered_minimum"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithMeteredMinimum(GroupedWithMeteredMinimum groupedWithMeteredMinimum) : base(groupedWithMeteredMinimum) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -25807,10 +28647,13 @@ public override void Validate() public GroupedWithMeteredMinimumCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumCompositePriceFilter( GroupedWithMeteredMinimumCompositePriceFilter groupedWithMeteredMinimumCompositePriceFilter ) : base(groupedWithMeteredMinimumCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumCompositePriceFilter( IReadOnlyDictionary rawData @@ -25996,7 +28839,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 +28860,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +28880,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +28891,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26078,7 +28921,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +28932,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -26139,10 +28982,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMeteredMinimumConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -26150,7 +28993,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMeteredMinimumConversionRateConfigConverter @@ -26185,12 +29041,10 @@ JsonSerializerOptions 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 +29061,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -26360,10 +29212,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfig) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfig( IReadOnlyDictionary rawData @@ -26441,10 +29296,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigScalingFactor( IReadOnlyDictionary rawData @@ -26528,10 +29386,13 @@ public override void Validate() public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount ) : base(groupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount) { } +#pragma warning restore CS8618 public GroupedWithMeteredMinimumGroupedWithMeteredMinimumConfigUnitAmount( IReadOnlyDictionary rawData @@ -26619,6 +29480,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMeteredMinimumLicenseType, + GroupedWithMeteredMinimumLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithMeteredMinimumLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithMeteredMinimumLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMeteredMinimumLicenseType( + GroupedWithMeteredMinimumLicenseType groupedWithMeteredMinimumLicenseType + ) + : base(groupedWithMeteredMinimumLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithMeteredMinimumLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMeteredMinimumLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMeteredMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMeteredMinimumLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithMeteredMinimumLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMeteredMinimumLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -26796,6 +29759,16 @@ public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsCon 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 { get @@ -26958,6 +29931,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() { @@ -26979,6 +29969,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedWithMinMaxThresholdsConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -27000,6 +29991,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -27010,11 +30002,14 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -27226,10 +30221,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsCompositePriceFilter( GroupedWithMinMaxThresholdsCompositePriceFilter groupedWithMinMaxThresholdsCompositePriceFilter ) : base(groupedWithMinMaxThresholdsCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsCompositePriceFilter( IReadOnlyDictionary rawData @@ -27415,7 +30413,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 +30434,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +30454,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +30465,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27497,7 +30495,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +30506,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -27558,10 +30556,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -27569,7 +30567,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -27604,12 +30615,10 @@ JsonSerializerOptions 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 +30635,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -27729,10 +30736,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -27812,6 +30822,108 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedWithMinMaxThresholdsLicenseType, + GroupedWithMinMaxThresholdsLicenseTypeFromRaw + >) +)] +public sealed record class GroupedWithMinMaxThresholdsLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedWithMinMaxThresholdsLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholdsLicenseType( + GroupedWithMinMaxThresholdsLicenseType groupedWithMinMaxThresholdsLicenseType + ) + : base(groupedWithMinMaxThresholdsLicenseType) { } +#pragma warning restore CS8618 + + public GroupedWithMinMaxThresholdsLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedWithMinMaxThresholdsLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedWithMinMaxThresholdsLicenseTypeFromRaw + : IFromRawJson +{ + /// + public GroupedWithMinMaxThresholdsLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedWithMinMaxThresholdsLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MatrixWithDisplayName : JsonModel { @@ -27972,6 +31084,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 @@ -28149,6 +31271,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() { @@ -28169,6 +31306,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.MatrixWithDisplayNameConfig.Validate(); @@ -28191,6 +31329,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -28201,11 +31340,14 @@ public MatrixWithDisplayName() this.ModelType = JsonSerializer.SerializeToElement("matrix_with_display_name"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MatrixWithDisplayName(MatrixWithDisplayName matrixWithDisplayName) : base(matrixWithDisplayName) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -28413,10 +31555,13 @@ public override void Validate() public MatrixWithDisplayNameCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameCompositePriceFilter( MatrixWithDisplayNameCompositePriceFilter matrixWithDisplayNameCompositePriceFilter ) : base(matrixWithDisplayNameCompositePriceFilter) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameCompositePriceFilter( IReadOnlyDictionary rawData @@ -28601,7 +31746,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 +31767,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +31787,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +31798,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28683,7 +31828,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +31839,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -28744,10 +31889,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MatrixWithDisplayNameConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -28755,7 +31900,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MatrixWithDisplayNameConversionRateConfigConverter @@ -28790,12 +31948,10 @@ JsonSerializerOptions 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 +31968,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -28897,10 +32051,13 @@ public override void Validate() public MatrixWithDisplayNameMatrixWithDisplayNameConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameMatrixWithDisplayNameConfig( MatrixWithDisplayNameMatrixWithDisplayNameConfig matrixWithDisplayNameMatrixWithDisplayNameConfig ) : base(matrixWithDisplayNameMatrixWithDisplayNameConfig) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameMatrixWithDisplayNameConfig( IReadOnlyDictionary rawData @@ -28995,10 +32152,13 @@ public override void Validate() public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount ) : base(matrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount) { } +#pragma warning restore CS8618 public MatrixWithDisplayNameMatrixWithDisplayNameConfigUnitAmount( IReadOnlyDictionary rawData @@ -29082,6 +32242,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MatrixWithDisplayNameLicenseType, + MatrixWithDisplayNameLicenseTypeFromRaw + >) +)] +public sealed record class MatrixWithDisplayNameLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MatrixWithDisplayNameLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MatrixWithDisplayNameLicenseType( + MatrixWithDisplayNameLicenseType matrixWithDisplayNameLicenseType + ) + : base(matrixWithDisplayNameLicenseType) { } +#pragma warning restore CS8618 + + public MatrixWithDisplayNameLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MatrixWithDisplayNameLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MatrixWithDisplayNameLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MatrixWithDisplayNameLicenseTypeFromRaw : IFromRawJson +{ + /// + public MatrixWithDisplayNameLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MatrixWithDisplayNameLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class GroupedTieredPackage : JsonModel { @@ -29257,6 +32518,16 @@ public required GroupedTieredPackageGroupedTieredPackageConfig GroupedTieredPack 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 @@ -29419,6 +32690,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() { @@ -29440,6 +32726,7 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; this.GroupedTieredPackageConfig.Validate(); + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -29461,6 +32748,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -29471,11 +32759,14 @@ public GroupedTieredPackage() this.ModelType = JsonSerializer.SerializeToElement("grouped_tiered_package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public GroupedTieredPackage(GroupedTieredPackage groupedTieredPackage) : base(groupedTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -29683,10 +32974,13 @@ public override void Validate() public GroupedTieredPackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageCompositePriceFilter( GroupedTieredPackageCompositePriceFilter groupedTieredPackageCompositePriceFilter ) : base(groupedTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 public GroupedTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData @@ -29871,7 +33165,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 +33186,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +33206,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +33217,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -29953,7 +33247,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +33258,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -30014,10 +33308,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -30025,7 +33319,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedTieredPackageConversionRateConfigConverter @@ -30060,12 +33367,10 @@ JsonSerializerOptions 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 +33387,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -30180,10 +33483,13 @@ public override void Validate() public GroupedTieredPackageGroupedTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageGroupedTieredPackageConfig( GroupedTieredPackageGroupedTieredPackageConfig groupedTieredPackageGroupedTieredPackageConfig ) : base(groupedTieredPackageGroupedTieredPackageConfig) { } +#pragma warning restore CS8618 public GroupedTieredPackageGroupedTieredPackageConfig( IReadOnlyDictionary rawData @@ -30261,10 +33567,13 @@ public override void Validate() public GroupedTieredPackageGroupedTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedTieredPackageGroupedTieredPackageConfigTier( GroupedTieredPackageGroupedTieredPackageConfigTier groupedTieredPackageGroupedTieredPackageConfigTier ) : base(groupedTieredPackageGroupedTieredPackageConfigTier) { } +#pragma warning restore CS8618 public GroupedTieredPackageGroupedTieredPackageConfigTier( IReadOnlyDictionary rawData @@ -30348,6 +33657,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + GroupedTieredPackageLicenseType, + GroupedTieredPackageLicenseTypeFromRaw + >) +)] +public sealed record class GroupedTieredPackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public GroupedTieredPackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedTieredPackageLicenseType( + GroupedTieredPackageLicenseType groupedTieredPackageLicenseType + ) + : base(groupedTieredPackageLicenseType) { } +#pragma warning restore CS8618 + + public GroupedTieredPackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + GroupedTieredPackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static GroupedTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class GroupedTieredPackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public GroupedTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => GroupedTieredPackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MaxGroupTieredPackage : JsonModel { @@ -30508,6 +33918,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 @@ -30685,6 +34105,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() { @@ -30705,6 +34140,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.MaxGroupTieredPackageConfig.Validate(); @@ -30727,6 +34163,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -30737,11 +34174,14 @@ public MaxGroupTieredPackage() this.ModelType = JsonSerializer.SerializeToElement("max_group_tiered_package"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public MaxGroupTieredPackage(MaxGroupTieredPackage maxGroupTieredPackage) : base(maxGroupTieredPackage) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -30949,10 +34389,13 @@ public override void Validate() public MaxGroupTieredPackageCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageCompositePriceFilter( MaxGroupTieredPackageCompositePriceFilter maxGroupTieredPackageCompositePriceFilter ) : base(maxGroupTieredPackageCompositePriceFilter) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageCompositePriceFilter( IReadOnlyDictionary rawData @@ -31137,7 +34580,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 +34601,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +34621,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +34632,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31219,7 +34662,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +34673,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -31280,10 +34723,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(MaxGroupTieredPackageConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -31291,7 +34734,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class MaxGroupTieredPackageConversionRateConfigConverter @@ -31326,12 +34782,10 @@ JsonSerializerOptions 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 +34802,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -31445,10 +34897,13 @@ public override void Validate() public MaxGroupTieredPackageMaxGroupTieredPackageConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageMaxGroupTieredPackageConfig( MaxGroupTieredPackageMaxGroupTieredPackageConfig maxGroupTieredPackageMaxGroupTieredPackageConfig ) : base(maxGroupTieredPackageMaxGroupTieredPackageConfig) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageMaxGroupTieredPackageConfig( IReadOnlyDictionary rawData @@ -31526,10 +34981,13 @@ public override void Validate() public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( MaxGroupTieredPackageMaxGroupTieredPackageConfigTier maxGroupTieredPackageMaxGroupTieredPackageConfigTier ) : base(maxGroupTieredPackageMaxGroupTieredPackageConfigTier) { } +#pragma warning restore CS8618 public MaxGroupTieredPackageMaxGroupTieredPackageConfigTier( IReadOnlyDictionary rawData @@ -31613,6 +35071,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + MaxGroupTieredPackageLicenseType, + MaxGroupTieredPackageLicenseTypeFromRaw + >) +)] +public sealed record class MaxGroupTieredPackageLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public MaxGroupTieredPackageLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MaxGroupTieredPackageLicenseType( + MaxGroupTieredPackageLicenseType maxGroupTieredPackageLicenseType + ) + : base(maxGroupTieredPackageLicenseType) { } +#pragma warning restore CS8618 + + public MaxGroupTieredPackageLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MaxGroupTieredPackageLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MaxGroupTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MaxGroupTieredPackageLicenseTypeFromRaw : IFromRawJson +{ + /// + public MaxGroupTieredPackageLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MaxGroupTieredPackageLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -31775,6 +35334,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 @@ -31952,6 +35521,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() { @@ -31972,6 +35558,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -31994,6 +35581,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithUnitPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -32004,6 +35592,8 @@ public ScalableMatrixWithUnitPricing() this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_unit_pricing"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] @@ -32011,6 +35601,7 @@ public ScalableMatrixWithUnitPricing( ScalableMatrixWithUnitPricing scalableMatrixWithUnitPricing ) : base(scalableMatrixWithUnitPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -32222,10 +35813,13 @@ public override void Validate() public ScalableMatrixWithUnitPricingCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingCompositePriceFilter( ScalableMatrixWithUnitPricingCompositePriceFilter scalableMatrixWithUnitPricingCompositePriceFilter ) : base(scalableMatrixWithUnitPricingCompositePriceFilter) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingCompositePriceFilter( IReadOnlyDictionary rawData @@ -32412,7 +36006,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 +36027,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +36047,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +36058,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32494,7 +36088,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +36099,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -32555,10 +36149,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ScalableMatrixWithUnitPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -32566,7 +36160,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithUnitPricingConversionRateConfigConverter @@ -32601,12 +36208,10 @@ JsonSerializerOptions 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 +36228,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -32758,6 +36361,19 @@ public required string UnitPrice init { this._rawData.Set("unit_price", value); } } + /// + /// The property used to group this price + /// + public string? GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + /// /// If true, the unit price will be prorated to the billing period /// @@ -32793,16 +36409,20 @@ public override void Validate() item.Validate(); } _ = this.UnitPrice; + _ = this.GroupingKey; _ = this.Prorate; _ = this.SecondDimension; } public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig ) : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfig( IReadOnlyDictionary rawData @@ -32891,11 +36511,14 @@ public override void Validate() public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor ) : base(scalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor) { } +#pragma warning restore CS8618 public ScalableMatrixWithUnitPricingScalableMatrixWithUnitPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -32935,6 +36558,110 @@ IReadOnlyDictionary rawData ); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithUnitPricingLicenseType, + ScalableMatrixWithUnitPricingLicenseTypeFromRaw + >) +)] +public sealed record class ScalableMatrixWithUnitPricingLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public ScalableMatrixWithUnitPricingLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithUnitPricingLicenseType( + ScalableMatrixWithUnitPricingLicenseType scalableMatrixWithUnitPricingLicenseType + ) + : base(scalableMatrixWithUnitPricingLicenseType) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithUnitPricingLicenseType( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithUnitPricingLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithUnitPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithUnitPricingLicenseTypeFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithUnitPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithUnitPricingLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter< ScalableMatrixWithTieredPricing, @@ -33100,6 +36827,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 @@ -33277,6 +37014,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() { @@ -33297,6 +37051,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -33319,6 +37074,7 @@ public override void Validate() _ = this.ReplacesPriceID; this.ScalableMatrixWithTieredPricingConfig.Validate(); this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -33329,6 +37085,8 @@ public ScalableMatrixWithTieredPricing() this.ModelType = JsonSerializer.SerializeToElement("scalable_matrix_with_tiered_pricing"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] @@ -33336,6 +37094,7 @@ public ScalableMatrixWithTieredPricing( ScalableMatrixWithTieredPricing scalableMatrixWithTieredPricing ) : base(scalableMatrixWithTieredPricing) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -33547,10 +37306,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingCompositePriceFilter( ScalableMatrixWithTieredPricingCompositePriceFilter scalableMatrixWithTieredPricingCompositePriceFilter ) : base(scalableMatrixWithTieredPricingCompositePriceFilter) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingCompositePriceFilter( IReadOnlyDictionary rawData @@ -33739,7 +37501,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 +37522,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +37542,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +37553,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33821,7 +37583,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +37594,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -33882,10 +37644,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(ScalableMatrixWithTieredPricingConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -33893,7 +37655,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class ScalableMatrixWithTieredPricingConversionRateConfigConverter @@ -33928,12 +37703,10 @@ JsonSerializerOptions 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 +37723,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -34119,10 +37890,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig ) : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfig( IReadOnlyDictionary rawData @@ -34215,12 +37989,15 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) : base( scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor ) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigMatrixScalingFactor( IReadOnlyDictionary rawData @@ -34301,10 +38078,13 @@ public override void Validate() public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier ) : base(scalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier) { } +#pragma warning restore CS8618 public ScalableMatrixWithTieredPricingScalableMatrixWithTieredPricingConfigTier( IReadOnlyDictionary rawData @@ -34344,6 +38124,110 @@ IReadOnlyDictionary rawData ); } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + ScalableMatrixWithTieredPricingLicenseType, + ScalableMatrixWithTieredPricingLicenseTypeFromRaw + >) +)] +public sealed record class ScalableMatrixWithTieredPricingLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public ScalableMatrixWithTieredPricingLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ScalableMatrixWithTieredPricingLicenseType( + ScalableMatrixWithTieredPricingLicenseType scalableMatrixWithTieredPricingLicenseType + ) + : base(scalableMatrixWithTieredPricingLicenseType) { } +#pragma warning restore CS8618 + + public ScalableMatrixWithTieredPricingLicenseType( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + ScalableMatrixWithTieredPricingLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static ScalableMatrixWithTieredPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class ScalableMatrixWithTieredPricingLicenseTypeFromRaw + : IFromRawJson +{ + /// + public ScalableMatrixWithTieredPricingLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ScalableMatrixWithTieredPricingLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class CumulativeGroupedBulk : JsonModel { @@ -34519,6 +38403,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 @@ -34681,6 +38575,21 @@ public DimensionalPriceConfiguration? DimensionalPriceConfiguration init { this._rawData.Set("dimensional_price_configuration", value); } } + /// + /// The LicenseType resource represents a type of license that can be assigned + /// to users. License types are used during billing by grouping metrics on the + /// configured grouping key. + /// + public CumulativeGroupedBulkLicenseType? LicenseType + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type"); + } + init { this._rawData.Set("license_type", value); } + } + /// public override void Validate() { @@ -34702,6 +38611,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -34723,6 +38633,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -34733,11 +38644,14 @@ public CumulativeGroupedBulk() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_bulk"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public CumulativeGroupedBulk(CumulativeGroupedBulk cumulativeGroupedBulk) : base(cumulativeGroupedBulk) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -34945,10 +38859,13 @@ public override void Validate() public CumulativeGroupedBulkCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCompositePriceFilter( CumulativeGroupedBulkCompositePriceFilter cumulativeGroupedBulkCompositePriceFilter ) : base(cumulativeGroupedBulkCompositePriceFilter) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCompositePriceFilter( IReadOnlyDictionary rawData @@ -35133,7 +39050,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 +39071,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +39091,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +39102,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -35215,7 +39132,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +39143,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -35276,10 +39193,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedBulkConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -35287,7 +39204,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 @@ -35322,12 +39252,10 @@ JsonSerializerOptions 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 +39272,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -35426,10 +39352,13 @@ public override void Validate() public CumulativeGroupedBulkCumulativeGroupedBulkConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCumulativeGroupedBulkConfig( CumulativeGroupedBulkCumulativeGroupedBulkConfig cumulativeGroupedBulkCumulativeGroupedBulkConfig ) : base(cumulativeGroupedBulkCumulativeGroupedBulkConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCumulativeGroupedBulkConfig( IReadOnlyDictionary rawData @@ -35525,10 +39454,13 @@ public override void Validate() public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue ) : base(cumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue) { } +#pragma warning restore CS8618 public CumulativeGroupedBulkCumulativeGroupedBulkConfigDimensionValue( IReadOnlyDictionary rawData @@ -35612,6 +39544,107 @@ JsonSerializerOptions options } } +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedBulkLicenseType, + CumulativeGroupedBulkLicenseTypeFromRaw + >) +)] +public sealed record class CumulativeGroupedBulkLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public CumulativeGroupedBulkLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedBulkLicenseType( + CumulativeGroupedBulkLicenseType cumulativeGroupedBulkLicenseType + ) + : base(cumulativeGroupedBulkLicenseType) { } +#pragma warning restore CS8618 + + public CumulativeGroupedBulkLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedBulkLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedBulkLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedBulkLicenseTypeFromRaw : IFromRawJson +{ + /// + public CumulativeGroupedBulkLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedBulkLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter( typeof(JsonModelConverter) )] @@ -35789,6 +39822,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 @@ -35951,6 +39994,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() { @@ -35972,6 +40032,7 @@ public override void Validate() this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -35993,6 +40054,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -36003,11 +40065,14 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" @@ -36219,10 +40284,13 @@ public override void Validate() public CumulativeGroupedAllocationCompositePriceFilter() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationCompositePriceFilter( CumulativeGroupedAllocationCompositePriceFilter cumulativeGroupedAllocationCompositePriceFilter ) : base(cumulativeGroupedAllocationCompositePriceFilter) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationCompositePriceFilter( IReadOnlyDictionary rawData @@ -36408,7 +40476,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 +40497,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +40517,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +40528,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36490,7 +40558,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +40569,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -36551,10 +40619,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -36562,7 +40630,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 @@ -36597,12 +40678,10 @@ JsonSerializerOptions 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 +40698,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -36722,10 +40799,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -36805,8 +40885,110 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceMinimum : JsonModel +/// +/// The LicenseType resource represents a type of license that can be assigned to +/// users. License types are used during billing by grouping metrics on the configured +/// grouping key. +/// +[JsonConverter( + typeof(JsonModelConverter< + CumulativeGroupedAllocationLicenseType, + CumulativeGroupedAllocationLicenseTypeFromRaw + >) +)] +public sealed record class CumulativeGroupedAllocationLicenseType : JsonModel +{ + /// + /// The Orb-assigned unique identifier for the license type. + /// + public required string ID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("id"); + } + init { this._rawData.Set("id", value); } + } + + /// + /// The key used for grouping licenses of this type. This is typically a user + /// identifier field. + /// + public required string GroupingKey + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("grouping_key"); + } + init { this._rawData.Set("grouping_key", value); } + } + + /// + /// The name of the license type. + /// + public required string Name + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("name"); + } + init { this._rawData.Set("name", value); } + } + + /// + public override void Validate() + { + _ = this.ID; + _ = this.GroupingKey; + _ = this.Name; + } + + public CumulativeGroupedAllocationLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocationLicenseType( + CumulativeGroupedAllocationLicenseType cumulativeGroupedAllocationLicenseType + ) + : base(cumulativeGroupedAllocationLicenseType) { } +#pragma warning restore CS8618 + + public CumulativeGroupedAllocationLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + CumulativeGroupedAllocationLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static CumulativeGroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class CumulativeGroupedAllocationLicenseTypeFromRaw + : IFromRawJson +{ + /// + public CumulativeGroupedAllocationLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => CumulativeGroupedAllocationLicenseType.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : JsonModel { public required string ID { @@ -36840,40 +41022,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 +41074,12 @@ public required double? ConversionRate init { this._rawData.Set("conversion_rate", value); } } - public required PriceMinimumConversionRateConfig? ConversionRateConfig + public required DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -36932,6 +41116,21 @@ public required string Currency init { this._rawData.Set("currency", 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); } + } + [System::Obsolete("deprecated")] public required SharedDiscount? Discount { @@ -36963,6 +41162,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 @@ -37054,19 +41263,6 @@ public required string? MinimumAmount init { this._rawData.Set("minimum_amount", value); } } - /// - /// Configuration for minimum pricing - /// - public required MinimumConfig MinimumConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_config"); - } - init { this._rawData.Set("minimum_config", value); } - } - /// /// The pricing model type /// @@ -37100,12 +41296,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 +41334,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() { @@ -37155,9 +41366,11 @@ public override void Validate() _ = this.CreatedAt; this.CreditAllocation?.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); this.Discount?.Validate(); _ = this.ExternalPriceID; _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); this.Item.Validate(); this.Maximum?.Validate(); @@ -37165,8 +41378,12 @@ public override void Validate() _ = this.Metadata; this.Minimum?.Validate(); _ = this.MinimumAmount; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -37175,30 +41392,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 DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + 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 PriceMinimum(PriceMinimum priceMinimum) - : base(priceMinimum) { } + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 [System::Obsolete( "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] - public PriceMinimum(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 @@ -37206,36 +41427,40 @@ public PriceMinimum(IReadOnlyDictionary rawData) "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" )] [SetsRequiredMembers] - PriceMinimum(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static DailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class PriceMinimumFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public PriceMinimum FromRawUnchecked(IReadOnlyDictionary rawData) => - PriceMinimum.FromRawUnchecked(rawData); + public DailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceMinimumBillingModeConverter))] -public enum PriceMinimumBillingMode +[JsonConverter(typeof(DailyCreditAllowanceBillingModeConverter))] +public enum DailyCreditAllowanceBillingMode { InAdvance, InArrear, } -sealed class PriceMinimumBillingModeConverter : JsonConverter +sealed class DailyCreditAllowanceBillingModeConverter + : JsonConverter { - public override PriceMinimumBillingMode Read( + public override DailyCreditAllowanceBillingMode Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37243,15 +41468,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "in_advance" => PriceMinimumBillingMode.InAdvance, - "in_arrear" => PriceMinimumBillingMode.InArrear, - _ => (PriceMinimumBillingMode)(-1), + "in_advance" => DailyCreditAllowanceBillingMode.InAdvance, + "in_arrear" => DailyCreditAllowanceBillingMode.InArrear, + _ => (DailyCreditAllowanceBillingMode)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumBillingMode value, + DailyCreditAllowanceBillingMode value, JsonSerializerOptions options ) { @@ -37259,8 +41484,8 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumBillingMode.InAdvance => "in_advance", - PriceMinimumBillingMode.InArrear => "in_arrear", + DailyCreditAllowanceBillingMode.InAdvance => "in_advance", + DailyCreditAllowanceBillingMode.InArrear => "in_arrear", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37270,8 +41495,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumCadenceConverter))] -public enum PriceMinimumCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { OneTime, Monthly, @@ -37281,9 +41506,9 @@ public enum PriceMinimumCadence Custom, } -sealed class PriceMinimumCadenceConverter : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override PriceMinimumCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37291,19 +41516,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" => 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, - PriceMinimumCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -37311,12 +41536,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", + 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)) ), @@ -37328,22 +41553,22 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceMinimumCompositePriceFilter, - PriceMinimumCompositePriceFilterFromRaw + DailyCreditAllowanceCompositePriceFilter, + DailyCreditAllowanceCompositePriceFilterFromRaw >) )] -public sealed record class PriceMinimumCompositePriceFilter : 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); } @@ -37352,13 +41577,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 +41616,33 @@ public override void Validate() _ = this.Values; } - public PriceMinimumCompositePriceFilter() { } + public DailyCreditAllowanceCompositePriceFilter() { } - public PriceMinimumCompositePriceFilter( - PriceMinimumCompositePriceFilter priceMinimumCompositePriceFilter +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceCompositePriceFilter( + DailyCreditAllowanceCompositePriceFilter dailyCreditAllowanceCompositePriceFilter ) - : base(priceMinimumCompositePriceFilter) { } + : base(dailyCreditAllowanceCompositePriceFilter) { } +#pragma warning restore CS8618 - public PriceMinimumCompositePriceFilter(IReadOnlyDictionary rawData) + public DailyCreditAllowanceCompositePriceFilter( + IReadOnlyDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceMinimumCompositePriceFilter(FrozenDictionary rawData) + DailyCreditAllowanceCompositePriceFilter(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static PriceMinimumCompositePriceFilter FromRawUnchecked( + /// + public static DailyCreditAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -37420,19 +41650,20 @@ IReadOnlyDictionary rawData } } -class PriceMinimumCompositePriceFilterFromRaw : IFromRawJson +class DailyCreditAllowanceCompositePriceFilterFromRaw + : IFromRawJson { /// - public PriceMinimumCompositePriceFilter FromRawUnchecked( + public DailyCreditAllowanceCompositePriceFilter FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceMinimumCompositePriceFilter.FromRawUnchecked(rawData); + ) => DailyCreditAllowanceCompositePriceFilter.FromRawUnchecked(rawData); } /// /// The property of the price to filter on. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterFieldConverter))] -public enum PriceMinimumCompositePriceFilterField +[JsonConverter(typeof(DailyCreditAllowanceCompositePriceFilterFieldConverter))] +public enum DailyCreditAllowanceCompositePriceFilterField { PriceID, ItemID, @@ -37441,10 +41672,10 @@ public enum PriceMinimumCompositePriceFilterField PricingUnitID, } -sealed class PriceMinimumCompositePriceFilterFieldConverter - : JsonConverter +sealed class DailyCreditAllowanceCompositePriceFilterFieldConverter + : JsonConverter { - public override PriceMinimumCompositePriceFilterField Read( + public override DailyCreditAllowanceCompositePriceFilterField Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37452,18 +41683,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" => 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, - PriceMinimumCompositePriceFilterField value, + DailyCreditAllowanceCompositePriceFilterField value, JsonSerializerOptions options ) { @@ -37471,11 +41702,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", + 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)) ), @@ -37488,17 +41719,17 @@ JsonSerializerOptions options /// /// Should prices that match the filter be included or excluded. /// -[JsonConverter(typeof(PriceMinimumCompositePriceFilterOperatorConverter))] -public enum PriceMinimumCompositePriceFilterOperator +[JsonConverter(typeof(DailyCreditAllowanceCompositePriceFilterOperatorConverter))] +public enum DailyCreditAllowanceCompositePriceFilterOperator { Includes, Excludes, } -sealed class PriceMinimumCompositePriceFilterOperatorConverter - : JsonConverter +sealed class DailyCreditAllowanceCompositePriceFilterOperatorConverter + : JsonConverter { - public override PriceMinimumCompositePriceFilterOperator Read( + public override DailyCreditAllowanceCompositePriceFilterOperator Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37506,15 +41737,15 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "includes" => PriceMinimumCompositePriceFilterOperator.Includes, - "excludes" => PriceMinimumCompositePriceFilterOperator.Excludes, - _ => (PriceMinimumCompositePriceFilterOperator)(-1), + "includes" => DailyCreditAllowanceCompositePriceFilterOperator.Includes, + "excludes" => DailyCreditAllowanceCompositePriceFilterOperator.Excludes, + _ => (DailyCreditAllowanceCompositePriceFilterOperator)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumCompositePriceFilterOperator value, + DailyCreditAllowanceCompositePriceFilterOperator value, JsonSerializerOptions options ) { @@ -37522,8 +41753,8 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumCompositePriceFilterOperator.Includes => "includes", - PriceMinimumCompositePriceFilterOperator.Excludes => "excludes", + DailyCreditAllowanceCompositePriceFilterOperator.Includes => "includes", + DailyCreditAllowanceCompositePriceFilterOperator.Excludes => "excludes", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -37533,8 +41764,8 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(PriceMinimumConversionRateConfigConverter))] -public record class PriceMinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -37551,7 +41782,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -37560,7 +41791,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -37569,7 +41800,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -37578,7 +41809,7 @@ public PriceMinimumConversionRateConfig(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -37599,7 +41830,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -37619,7 +41850,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -37630,8 +41861,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -37651,7 +41882,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PriceMinimumConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -37660,7 +41891,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -37671,8 +41902,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -37687,16 +41918,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator PriceMinimumConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator PriceMinimumConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -37715,16 +41946,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 DailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceMinimumConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -37732,13 +41963,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override PriceMinimumConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37767,12 +42011,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -37789,12 +42031,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -37803,14 +42043,14 @@ JsonSerializerOptions options } default: { - return new PriceMinimumConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - PriceMinimumConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -37819,102 +42059,248 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for daily_credit_allowance pricing /// -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class MinimumConfig : JsonModel +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string MinimumAmount + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("daily_allowance", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public bool? Prorated + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + 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 { - if (value == null) - { - return; - } + this._rawData.Set>( + "dimensions", + ImmutableArray.ToImmutableArray(value) + ); + } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public MinimumConfig() { } + public DailyCreditAllowanceConfig() { } - public MinimumConfig(MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) + /// + 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 MinimumConfig(string minimumAmount) - : this() + public DailyCreditAllowanceConfigMatrixValue( + DailyCreditAllowanceConfigMatrixValue dailyCreditAllowanceConfigMatrixValue + ) + : base(dailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceConfigMatrixValue(IReadOnlyDictionary rawData) { - this.MinimumAmount = minimumAmount; + 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 MinimumConfigFromRaw : IFromRawJson +class DailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public MinimumConfig FromRawUnchecked(IReadOnlyDictionary rawData) => - MinimumConfig.FromRawUnchecked(rawData); + public DailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(PriceMinimumPriceTypeConverter))] -public enum PriceMinimumPriceType +[JsonConverter(typeof(DailyCreditAllowancePriceTypeConverter))] +public enum DailyCreditAllowancePriceType { UsagePrice, FixedPrice, CompositePrice, } -sealed class PriceMinimumPriceTypeConverter : JsonConverter +sealed class DailyCreditAllowancePriceTypeConverter : JsonConverter { - public override PriceMinimumPriceType Read( + public override DailyCreditAllowancePriceType Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -37922,16 +42308,16 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "usage_price" => PriceMinimumPriceType.UsagePrice, - "fixed_price" => PriceMinimumPriceType.FixedPrice, - "composite_price" => PriceMinimumPriceType.CompositePrice, - _ => (PriceMinimumPriceType)(-1), + "usage_price" => DailyCreditAllowancePriceType.UsagePrice, + "fixed_price" => DailyCreditAllowancePriceType.FixedPrice, + "composite_price" => DailyCreditAllowancePriceType.CompositePrice, + _ => (DailyCreditAllowancePriceType)(-1), }; } public override void Write( Utf8JsonWriter writer, - PriceMinimumPriceType value, + DailyCreditAllowancePriceType value, JsonSerializerOptions options ) { @@ -37939,9 +42325,9 @@ JsonSerializerOptions options writer, value switch { - PriceMinimumPriceType.UsagePrice => "usage_price", - PriceMinimumPriceType.FixedPrice => "fixed_price", - PriceMinimumPriceType.CompositePrice => "composite_price", + 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)) ), @@ -37951,6 +42337,1471 @@ 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< + DailyCreditAllowanceLicenseType, + DailyCreditAllowanceLicenseTypeFromRaw + >) +)] +public sealed record class DailyCreditAllowanceLicenseType : 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 DailyCreditAllowanceLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceLicenseType( + DailyCreditAllowanceLicenseType dailyCreditAllowanceLicenseType + ) + : base(dailyCreditAllowanceLicenseType) { } +#pragma warning restore CS8618 + + public DailyCreditAllowanceLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowanceLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceLicenseTypeFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowanceLicenseType.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowance : 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); } + } + + 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 MeteredAllowanceConversionRateConfig? 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) + ); + } + } + + /// + /// Configuration for metered_allowance pricing + /// + public required MeteredAllowanceConfig MeteredAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); + } + init { this._rawData.Set("metered_allowance_config", 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 MeteredAllowanceLicenseType? 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.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.MeteredAllowanceConfig.Validate(); + this.Minimum?.Validate(); + _ = this.MinimumAmount; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) + { + 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 MeteredAllowance() + { + 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 MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 + + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] + public MeteredAllowance(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); + } + +#pragma warning disable CS8618 + [System::Obsolete( + "Required properties are deprecated: discount, maximum, maximum_amount, minimum, minimum_amount" + )] + [SetsRequiredMembers] + MeteredAllowance(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MeteredAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MeteredAllowanceFromRaw : IFromRawJson +{ + /// + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(MeteredAllowanceBillingModeConverter))] +public enum MeteredAllowanceBillingMode +{ + InAdvance, + InArrear, +} + +sealed class MeteredAllowanceBillingModeConverter : JsonConverter +{ + public override MeteredAllowanceBillingMode Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "in_advance" => MeteredAllowanceBillingMode.InAdvance, + "in_arrear" => MeteredAllowanceBillingMode.InArrear, + _ => (MeteredAllowanceBillingMode)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowanceBillingMode value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + MeteredAllowanceBillingMode.InAdvance => "in_advance", + MeteredAllowanceBillingMode.InArrear => "in_arrear", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence +{ + OneTime, + Monthly, + Quarterly, + SemiAnnual, + Annual, + Custom, +} + +sealed class MeteredAllowanceCadenceConverter : JsonConverter +{ + public override MeteredAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + MeteredAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + MeteredAllowanceCompositePriceFilter, + MeteredAllowanceCompositePriceFilterFromRaw + >) +)] +public sealed record class MeteredAllowanceCompositePriceFilter : 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 MeteredAllowanceCompositePriceFilter() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceCompositePriceFilter( + MeteredAllowanceCompositePriceFilter meteredAllowanceCompositePriceFilter + ) + : base(meteredAllowanceCompositePriceFilter) { } +#pragma warning restore CS8618 + + public MeteredAllowanceCompositePriceFilter(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowanceCompositePriceFilter(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MeteredAllowanceCompositePriceFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MeteredAllowanceCompositePriceFilterFromRaw + : IFromRawJson +{ + /// + public MeteredAllowanceCompositePriceFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceCompositePriceFilter.FromRawUnchecked(rawData); +} + +/// +/// The property of the price to filter on. +/// +[JsonConverter(typeof(MeteredAllowanceCompositePriceFilterFieldConverter))] +public enum MeteredAllowanceCompositePriceFilterField +{ + PriceID, + ItemID, + PriceType, + Currency, + PricingUnitID, +} + +sealed class MeteredAllowanceCompositePriceFilterFieldConverter + : JsonConverter +{ + public override MeteredAllowanceCompositePriceFilterField Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + MeteredAllowanceCompositePriceFilterField value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Should prices that match the filter be included or excluded. +/// +[JsonConverter(typeof(MeteredAllowanceCompositePriceFilterOperatorConverter))] +public enum MeteredAllowanceCompositePriceFilterOperator +{ + Includes, + Excludes, +} + +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 MeteredAllowancePriceType Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "usage_price" => MeteredAllowancePriceType.UsagePrice, + "fixed_price" => MeteredAllowancePriceType.FixedPrice, + "composite_price" => MeteredAllowancePriceType.CompositePrice, + _ => (MeteredAllowancePriceType)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + MeteredAllowancePriceType value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + 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 MeteredAllowanceLicenseType : 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 MeteredAllowanceLicenseType() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceLicenseType(MeteredAllowanceLicenseType meteredAllowanceLicenseType) + : base(meteredAllowanceLicenseType) { } +#pragma warning restore CS8618 + + public MeteredAllowanceLicenseType(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + MeteredAllowanceLicenseType(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static MeteredAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class MeteredAllowanceLicenseTypeFromRaw : IFromRawJson +{ + /// + public MeteredAllowanceLicenseType FromRawUnchecked( + IReadOnlyDictionary rawData + ) => MeteredAllowanceLicenseType.FromRawUnchecked(rawData); +} + [JsonConverter(typeof(JsonModelConverter))] public sealed record class MinimumComposite : JsonModel { @@ -38111,6 +43962,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 +44149,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 +44184,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 +44207,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -38340,11 +44218,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 +44431,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 +44620,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 +44641,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +44661,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +44672,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38818,7 +44702,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +44713,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -38879,10 +44763,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 +44774,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +44822,10 @@ JsonSerializerOptions 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 +44842,10 @@ JsonSerializerOptions 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 +44923,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 +45016,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 +45270,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 +45453,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 +45488,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 +45506,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -39498,11 +45517,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 +45725,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 +45911,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 +45932,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +45952,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +45963,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -39968,7 +45993,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +46004,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -40029,10 +46054,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 +46065,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +46112,10 @@ JsonSerializerOptions 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 +46132,10 @@ JsonSerializerOptions 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 +46186,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 +46273,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 +46537,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 +46709,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 +46745,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 +46767,7 @@ public override void Validate() this.PriceType.Validate(); _ = this.ReplacesPriceID; this.DimensionalPriceConfiguration?.Validate(); + this.LicenseType?.Validate(); } [System::Obsolete( @@ -40621,11 +46778,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 +46989,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 +47177,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 +47198,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +47218,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +47229,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41096,7 +47259,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +47270,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -41157,10 +47320,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 +47331,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +47379,10 @@ JsonSerializerOptions 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 +47399,10 @@ JsonSerializerOptions 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 +47484,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 +47572,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..a191948b0 100644 --- a/src/Orb/Models/Prices/PriceCreateParams.cs +++ b/src/Orb/Models/Prices/PriceCreateParams.cs @@ -23,45 +23,44 @@ namespace Orb.Models.Prices; /// /// See the [Price resource](/product-catalog/price-configuration) for the /// specification of different price model configurations possible in this endpoint. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceCreateParams : ParamsBase +public record class PriceCreateParams : ParamsBase { - readonly JsonDictionary _rawBodyData = new(); - public IReadOnlyDictionary RawBodyData - { - get { return this._rawBodyData.Freeze(); } - } + public JsonElement RawBodyData { get; private init; } /// /// New floating price request body params. /// public required Body Body { - get - { - this._rawBodyData.Freeze(); - return this._rawBodyData.GetNotNullClass("body"); - } - init { this._rawBodyData.Set("body", value); } + get { return WrappedJsonSerializer.GetNotNullClass(this.RawBodyData, "RawBodyData"); } + init { this.RawBodyData = JsonSerializer.SerializeToElement(value); } } public PriceCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCreateParams(PriceCreateParams priceCreateParams) : base(priceCreateParams) { - this._rawBodyData = new(priceCreateParams._rawBodyData); + this.RawBodyData = priceCreateParams.RawBodyData; } +#pragma warning restore CS8618 public PriceCreateParams( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning disable CS8618 @@ -69,27 +68,55 @@ IReadOnlyDictionary rawBodyData PriceCreateParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + JsonElement rawBodyData ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); - this._rawBodyData = new(rawBodyData); + this.RawBodyData = rawBodyData; } #pragma warning restore CS8618 - /// + /// public static PriceCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + JsonElement rawBodyData ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + rawBodyData + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this.RawBodyData), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(PriceCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this.RawBodyData.Equals(other.RawBodyData); } public override System::Uri Url(ClientOptions options) @@ -117,6 +144,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } /// @@ -173,7 +205,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 @@ -214,7 +247,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 @@ -255,7 +289,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 @@ -296,7 +331,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 @@ -337,7 +373,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 @@ -378,7 +415,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 @@ -419,7 +457,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 @@ -462,7 +501,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 @@ -503,7 +543,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 @@ -544,7 +585,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 @@ -585,7 +627,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 @@ -627,7 +670,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 +679,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnitPrice: (x) => x.LicenseTypeID, + newFloatingTieredPrice: (x) => x.LicenseTypeID, + newFloatingBulkPrice: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackagePrice: (x) => x.LicenseTypeID, + newFloatingMatrixPrice: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmountPrice: (x) => x.LicenseTypeID, + newFloatingTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimumPrice: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPrice: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimumPrice: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocationPrice: (x) => x.LicenseTypeID, + newFloatingUnitWithPercentPrice: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocationPrice: (x) => x.LicenseTypeID, + newFloatingTieredWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingUnitWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingGroupedAllocationPrice: (x) => x.LicenseTypeID, + newFloatingBulkWithProrationPrice: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimumPrice: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimumPrice: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayNamePrice: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackagePrice: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricingPrice: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricingPrice: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulkPrice: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + 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 +739,7 @@ public Body(NewFloatingBulkPrice value, JsonElement? element = null) this._element = element; } - public Body(global::Orb.Models.Prices.BulkWithFilters value, JsonElement? element = null) + public Body(BulkWithFilters value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -755,10 +841,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 +883,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 +907,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 +928,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 +949,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 +970,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 +989,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 +1012,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 +1035,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 +1056,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 +1079,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 +1102,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 +1125,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 +1148,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 +1171,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 +1194,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 +1217,7 @@ public bool TryPickNewFloatingUnitWithPercentPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1156,7 +1240,7 @@ public bool TryPickNewFloatingMatrixWithAllocationPrice( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1179,7 +1263,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 +1286,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 +1309,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 +1332,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 +1355,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 +1376,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 +1401,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 +1424,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 +1447,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 +1470,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 +1493,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 +1516,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 +1537,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 +1604,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 +1625,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 +1679,39 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1616,7 +1720,7 @@ public void Switch( System::Action newFloatingUnitPrice, System::Action newFloatingTieredPrice, System::Action newFloatingBulkPrice, - System::Action bulkWithFilters, + System::Action bulkWithFilters, System::Action newFloatingPackagePrice, System::Action newFloatingMatrixPrice, System::Action newFloatingThresholdTotalAmountPrice, @@ -1633,18 +1737,19 @@ public void Switch( System::Action newFloatingBulkWithProrationPrice, System::Action newFloatingGroupedWithProratedMinimumPrice, System::Action newFloatingGroupedWithMeteredMinimumPrice, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newFloatingMatrixWithDisplayNamePrice, System::Action newFloatingGroupedTieredPackagePrice, System::Action newFloatingMaxGroupTieredPackagePrice, System::Action newFloatingScalableMatrixWithUnitPricingPrice, System::Action newFloatingScalableMatrixWithTieredPricingPrice, System::Action newFloatingCumulativeGroupedBulkPrice, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newFloatingMinimumCompositePrice, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -1658,7 +1763,7 @@ public void Switch( case NewFloatingBulkPrice value: newFloatingBulkPrice(value); break; - case global::Orb.Models.Prices.BulkWithFilters value: + case BulkWithFilters value: bulkWithFilters(value); break; case NewFloatingPackagePrice value: @@ -1709,7 +1814,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 +1835,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 +1862,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +1873,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.BulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Prices.GroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Prices.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.Minimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Prices.Percent value) => {...}, - /// (global::Orb.Models.Prices.EventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -1805,7 +1914,7 @@ public T Match( System::Func newFloatingUnitPrice, System::Func newFloatingTieredPrice, System::Func newFloatingBulkPrice, - System::Func bulkWithFilters, + System::Func bulkWithFilters, System::Func newFloatingPackagePrice, System::Func newFloatingMatrixPrice, System::Func newFloatingThresholdTotalAmountPrice, @@ -1834,10 +1943,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 +1965,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 +1978,7 @@ public T Match( NewFloatingUnitPrice value => newFloatingUnitPrice(value), NewFloatingTieredPrice value => newFloatingTieredPrice(value), NewFloatingBulkPrice value => newFloatingBulkPrice(value), - global::Orb.Models.Prices.BulkWithFilters value => bulkWithFilters(value), + BulkWithFilters value => bulkWithFilters(value), NewFloatingPackagePrice value => newFloatingPackagePrice(value), NewFloatingMatrixPrice value => newFloatingMatrixPrice(value), NewFloatingThresholdTotalAmountPrice value => newFloatingThresholdTotalAmountPrice( @@ -1900,8 +2004,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 +2021,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 +2037,7 @@ public T Match( public static implicit operator Body(NewFloatingBulkPrice value) => new(value); - public static implicit operator Body(global::Orb.Models.Prices.BulkWithFilters value) => - new(value); + public static implicit operator Body(BulkWithFilters value) => new(value); public static implicit operator Body(NewFloatingPackagePrice value) => new(value); @@ -1972,9 +2074,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 +2090,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(global::Orb.Models.Prices.Minimum value) => new(value); + public static implicit operator Body(DailyCreditAllowance 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 @@ -2059,17 +2159,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 +2178,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + NewFloatingMinimumCompositePrice _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -1, + }; + } } sealed class BodyConverter : JsonConverter @@ -2111,12 +2256,10 @@ JsonSerializerOptions 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 +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 } @@ -2155,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 } @@ -2171,19 +2310,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 +2336,10 @@ JsonSerializerOptions 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 +2356,10 @@ JsonSerializerOptions 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 +2377,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2267,12 +2397,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2290,12 +2418,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2312,12 +2438,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2335,12 +2459,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2358,12 +2480,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2380,12 +2500,10 @@ JsonSerializerOptions 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 +2521,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2426,12 +2542,10 @@ JsonSerializerOptions 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 +2563,10 @@ JsonSerializerOptions 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 +2584,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2495,12 +2605,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2518,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 } @@ -2541,12 +2647,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2557,19 +2661,16 @@ JsonSerializerOptions options { try { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); + var deserialized = JsonSerializer.Deserialize( + element, + options + ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2587,12 +2688,10 @@ JsonSerializerOptions 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 +2709,10 @@ JsonSerializerOptions 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 +2730,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2656,12 +2751,10 @@ JsonSerializerOptions 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 +2772,10 @@ JsonSerializerOptions 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 +2793,10 @@ JsonSerializerOptions 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 +2807,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 +2873,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2786,19 +2887,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 +2904,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 +2930,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 +2949,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 +3070,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 +3150,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3211,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3128,8 +3220,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 +3241,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 +3283,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 +3314,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 +3333,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 +3342,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 +3391,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 +3410,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 +3465,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 +3484,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 +3498,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 +3519,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 +3529,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 +3560,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 +3599,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 +3620,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +3640,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +3651,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3611,7 +3681,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +3692,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3643,13 +3713,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 +3740,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 +3751,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 +3798,10 @@ JsonSerializerOptions 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 +3818,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3754,14 +3830,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 +3846,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholds, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -3811,12 +3881,12 @@ public required string Currency /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -3921,12 +3991,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4003,6 +4073,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4051,6 +4134,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4059,10 +4143,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Prices.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -4079,8 +4164,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4088,19 +4173,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadenceConverter))] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -4112,9 +4196,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4122,23 +4206,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb - .Models - .Prices - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.OneTime, - "custom" => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -4146,14 +4226,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Annual => "annual", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsCadence.Custom => "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4168,8 +4246,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -4237,10 +4315,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -4255,8 +4336,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4264,18 +4345,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -4320,7 +4398,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 +4419,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +4439,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +4450,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4402,7 +4480,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +4491,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4434,11 +4512,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -4463,12 +4541,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4476,13 +4552,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4511,12 +4600,10 @@ JsonSerializerOptions 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 +4620,10 @@ JsonSerializerOptions 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 +4632,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -4565,26 +4648,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocation, - global::Orb.Models.Prices.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -4593,12 +4670,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Prices.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -4716,12 +4793,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -4798,6 +4875,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4846,6 +4936,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4854,10 +4945,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Prices.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -4874,8 +4966,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -4883,19 +4975,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationCadenceConverter))] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -4907,9 +4998,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Prices.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -4917,23 +5008,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Prices - .CumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Monthly, - "quarterly" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Quarterly, - "one_time" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.OneTime, - "custom" => global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Prices.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -4941,14 +5028,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Annual => "annual", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Monthly => "monthly", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Quarterly => - "quarterly", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.OneTime => "one_time", - global::Orb.Models.Prices.CumulativeGroupedAllocationCadence.Custom => "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -4963,8 +5048,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig, - global::Orb.Models.Prices.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -5032,10 +5117,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( - global::Orb.Models.Prices.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -5050,8 +5138,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5059,19 +5147,922 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Prices.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Prices.CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] +public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + ), + }; + } + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of CumulativeGroupedAllocationConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class CumulativeGroupedAllocationConversionRateConfigConverter + : JsonConverter +{ + public override CumulativeGroupedAllocationConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } + + switch (conversionRateType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + default: + { + return new CumulativeGroupedAllocationConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + CumulativeGroupedAllocationConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class DailyCreditAllowance : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" + ); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// 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. + /// + 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 DailyCreditAllowanceConversionRateConfig? 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.DailyCreditAllowanceConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) + { + 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 DailyCreditAllowance() + { + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 + + public DailyCreditAllowance(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + DailyCreditAllowance(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static DailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class DailyCreditAllowanceFromRaw : IFromRawJson +{ + /// + public DailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => DailyCreditAllowance.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter +{ + public override DailyCreditAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + DailyCreditAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing +/// [JsonConverter( - typeof(global::Orb.Models.Prices.CumulativeGroupedAllocationConversionRateConfigConverter) + typeof(JsonModelConverter) )] -public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase +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>("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))] +public sealed record class MatrixValue : 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 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(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -5088,7 +6079,7 @@ public JsonElement Json } } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5097,7 +6088,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5106,7 +6097,7 @@ public CumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public CumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5115,7 +6106,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 +6127,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6147,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6158,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5188,7 +6179,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 +6188,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6199,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5224,16 +6215,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 +6243,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 +6260,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 +6308,10 @@ JsonSerializerOptions 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 +6328,10 @@ JsonSerializerOptions 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 +6340,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 +6355,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 +6400,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 +6499,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 +6581,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +6621,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 +6642,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 +6681,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 +6702,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 +6712,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 +6732,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 +6748,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 +6848,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 +6919,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -5854,7 +6928,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -5863,7 +6937,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -5872,7 +6946,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 +6967,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6987,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6998,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5945,7 +7019,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 +7028,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7039,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5981,16 +7055,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 +7083,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 +7100,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 +7148,10 @@ JsonSerializerOptions 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 +7168,10 @@ JsonSerializerOptions 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 +7180,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 +7195,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 +7266,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 +7335,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 +7417,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7473,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6393,8 +7482,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 +7503,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 +7531,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 +7541,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 +7561,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 +7579,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 +7603,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 +7622,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 +7636,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 +7688,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 +7709,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7729,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7740,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6686,7 +7770,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7781,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6718,11 +7802,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 +7831,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 +7842,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 +7889,10 @@ JsonSerializerOptions 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 +7909,10 @@ JsonSerializerOptions 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 +7921,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 +7936,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 +7968,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 +8076,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 +8158,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8219,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7131,8 +8228,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 +8249,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 +8277,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 +8287,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 +8307,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 +8325,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 +8380,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 +8399,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 +8415,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 +8467,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 +8488,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8508,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8519,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7456,7 +8549,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8560,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7488,11 +8581,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 +8610,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 +8621,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 +8669,10 @@ JsonSerializerOptions 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 +8689,10 @@ JsonSerializerOptions 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 +8701,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..1f375e207 100644 --- a/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluateMultipleParams.cs @@ -39,8 +39,12 @@ namespace Orb.Models.Prices; /// /// Note that this is a POST endpoint rather than a GET endpoint because it /// employs a JSON body rather than query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceEvaluateMultipleParams : ParamsBase +public record class PriceEvaluateMultipleParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -128,11 +132,14 @@ public IReadOnlyList? PriceEvaluations public PriceEvaluateMultipleParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluateMultipleParams(PriceEvaluateMultipleParams priceEvaluateMultipleParams) : base(priceEvaluateMultipleParams) { this._rawBodyData = new(priceEvaluateMultipleParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluateMultipleParams( IReadOnlyDictionary rawHeaderData, @@ -159,7 +166,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PriceEvaluateMultipleParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -173,6 +180,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceEvaluateMultipleParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/prices/evaluate") @@ -198,6 +233,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -255,15 +295,37 @@ public IReadOnlyList? GroupingKeys } } + /// + /// Optional overrides for parameterized billable metric parameters. If the metric + /// has parameter definitions and no overrides are provided, defaults will be used. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// New floating price request body params. /// - public global::Orb.Models.Prices.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -287,14 +349,18 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } public PriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluation(PriceEvaluation priceEvaluation) : base(priceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluation(IReadOnlyDictionary rawData) { @@ -326,7 +392,7 @@ public PriceEvaluation FromRawUnchecked(IReadOnlyDictionary /// /// New floating price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Prices.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -377,7 +443,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 @@ -418,7 +485,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 @@ -459,7 +527,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 @@ -500,7 +569,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 @@ -541,7 +611,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 @@ -582,7 +653,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 @@ -623,7 +695,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 @@ -664,7 +737,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 @@ -705,7 +779,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 @@ -746,7 +821,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 @@ -787,7 +863,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 @@ -828,7 +905,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 +914,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + 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; @@ -1004,7 +1124,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 +1163,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 +1184,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 +1205,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 +1226,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 +1247,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 +1268,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 +1289,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 +1312,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 +1335,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 +1358,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 +1381,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 +1404,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 +1427,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 +1450,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1347,7 +1473,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1370,7 +1496,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 +1519,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 +1542,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 +1565,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 +1588,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 +1611,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 +1634,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 +1657,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 +1680,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 +1703,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 +1726,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 +1749,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 +1772,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 +1793,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 +1839,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 +1862,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 +1883,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 +1903,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 +1914,39 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceEventOutput? value) /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PricePercent value) => {...}, - /// (PriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (PriceDailyCreditAllowance value) => {...}, + /// (PriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput value) => {...} /// ); /// /// @@ -1832,7 +1980,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 @@ -1924,8 +2073,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 +2097,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +2108,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceCumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Prices.PriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PricePercent value) => {...}, - /// (PriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceCumulativeGroupedAllocation value) => {...}, + /// (PriceDailyCreditAllowance value) => {...}, + /// (PriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PricePercent value) => {...}, + /// (PriceEventOutput value) => {...} /// ); /// /// @@ -2036,7 +2189,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 @@ -2079,7 +2233,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 +2242,80 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingUnitPrice value) => - new(value); + public static implicit operator Price(NewFloatingUnitPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingTieredPrice value) => - new(value); + public static implicit operator Price(NewFloatingTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingBulkPrice value) => - new(value); + public static implicit operator Price(NewFloatingBulkPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceBulkWithFilters value) => - new(value); + public static implicit operator Price(PriceBulkWithFilters value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(NewFloatingMatrixPrice value) => - new(value); + public static implicit operator Price(NewFloatingMatrixPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingThresholdTotalAmountPrice value - ) => new(value); + public static implicit operator Price(NewFloatingThresholdTotalAmountPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithMinimumPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredPackageWithMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredPackageWithMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingPackageWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingPackageWithAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithPercentPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithPercentPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingTieredWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingTieredWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingUnitWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedAllocationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewFloatingBulkWithProrationPrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceGroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(PriceGroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingGroupedTieredPackagePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewFloatingMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithUnitPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithUnitPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingScalableMatrixWithTieredPricingPrice value - ) => new(value); + public static implicit operator Price(NewFloatingScalableMatrixWithTieredPricingPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewFloatingCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Prices.Price( - PriceCumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(PriceCumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - global::Orb.Models.Prices.PriceMinimum value - ) => new(value); + public static implicit operator Price(PriceDailyCreditAllowance value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price( - NewFloatingMinimumCompositePrice value - ) => new(value); + public static implicit operator Price(PriceMeteredAllowance value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PricePercent value) => - new(value); + public static implicit operator Price(NewFloatingMinimumCompositePrice value) => new(value); - public static implicit operator global::Orb.Models.Prices.Price(PriceEventOutput 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 @@ -2257,17 +2366,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 +2385,56 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceCumulativeGroupedAllocation _ => 27, + PriceDailyCreditAllowance _ => 28, + PriceMeteredAllowance _ => 29, + NewFloatingMinimumCompositePrice _ => 30, + PricePercent _ => 31, + PriceEventOutput _ => 32, + _ => -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 +2463,10 @@ JsonSerializerOptions 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 +2483,10 @@ JsonSerializerOptions 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 +2503,10 @@ JsonSerializerOptions 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 +2523,10 @@ JsonSerializerOptions 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 +2543,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2419,12 +2563,10 @@ JsonSerializerOptions 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 +2584,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2464,12 +2604,10 @@ JsonSerializerOptions 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 +2625,10 @@ JsonSerializerOptions 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 +2645,10 @@ JsonSerializerOptions 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 +2666,10 @@ JsonSerializerOptions 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 +2687,10 @@ JsonSerializerOptions 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 +2707,10 @@ JsonSerializerOptions 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 +2728,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2623,12 +2749,10 @@ JsonSerializerOptions 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 +2770,10 @@ JsonSerializerOptions 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 +2791,10 @@ JsonSerializerOptions 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 +2812,10 @@ JsonSerializerOptions 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 +2833,10 @@ JsonSerializerOptions 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 +2854,10 @@ JsonSerializerOptions 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 +2874,10 @@ JsonSerializerOptions 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 +2895,10 @@ JsonSerializerOptions 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 +2916,10 @@ JsonSerializerOptions 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 +2937,10 @@ JsonSerializerOptions 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 +2958,10 @@ JsonSerializerOptions 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 +2979,10 @@ JsonSerializerOptions 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 +3000,10 @@ JsonSerializerOptions 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 +3020,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 +3080,10 @@ JsonSerializerOptions 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 +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 } @@ -3006,12 +3117,10 @@ JsonSerializerOptions 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 +3129,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 +3366,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3427,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3317,8 +3436,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 +3542,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 +3629,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 +3716,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 +3868,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 +3889,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +3909,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +3920,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3819,7 +3950,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +3961,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -3880,10 +4011,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 +4022,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +4070,10 @@ JsonSerializerOptions 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 +4090,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4208,6 +4348,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4256,6 +4409,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4264,10 +4418,13 @@ public PriceGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceGroupedWithMinMaxThresholds( PriceGroupedWithMinMaxThresholds priceGroupedWithMinMaxThresholds ) : base(priceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -4436,10 +4593,13 @@ public override void Validate() public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(priceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public PriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -4522,7 +4682,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 +4703,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +4723,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +4734,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4604,7 +4764,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +4775,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4665,10 +4825,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -4676,7 +4836,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -4711,12 +4884,10 @@ JsonSerializerOptions 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 +4904,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4993,6 +5162,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5041,6 +5223,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5049,10 +5232,13 @@ public PriceCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCumulativeGroupedAllocation( PriceCumulativeGroupedAllocation priceCumulativeGroupedAllocation ) : base(priceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -5221,10 +5407,13 @@ public override void Validate() public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(priceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public PriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -5307,7 +5496,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 +5517,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5537,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5548,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5389,7 +5578,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5589,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5450,10 +5639,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5461,7 +5650,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -5496,12 +5698,10 @@ JsonSerializerOptions 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 +5718,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5548,24 +5746,21 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Prices.PriceMinimum, - global::Orb.Models.Prices.PriceMinimumFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class PriceMinimum : 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); } } @@ -5584,29 +5779,31 @@ public required string Currency } /// - /// The id of the item the price will be associated with. + /// Configuration for daily_credit_allowance pricing /// - public required string ItemID + public required PriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required PriceMinimumMinimumConfig 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); } } /// @@ -5694,12 +5891,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 PriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5776,6 +5973,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5802,12 +6012,951 @@ public override void Validate() { this.Cadence.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) - { - throw new OrbInvalidDataException("Invalid value given for constant"); - } + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) + { + 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 PriceDailyCreditAllowance() + { + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceDailyCreditAllowance(PriceDailyCreditAllowance priceDailyCreditAllowance) + : base(priceDailyCreditAllowance) { } +#pragma warning restore CS8618 + + public PriceDailyCreditAllowance(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceDailyCreditAllowance(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceDailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceDailyCreditAllowanceFromRaw : IFromRawJson +{ + /// + public PriceDailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceDailyCreditAllowance.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceDailyCreditAllowanceCadenceConverter))] +public enum PriceDailyCreditAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceDailyCreditAllowanceCadenceConverter + : JsonConverter +{ + public override PriceDailyCreditAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PriceDailyCreditAllowanceCadence value, + JsonSerializerOptions 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); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + : 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 PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) + : base(priceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked(rawData); +} + +[JsonConverter(typeof(PriceDailyCreditAllowanceConversionRateConfigConverter))] +public record class PriceDailyCreditAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceDailyCreditAllowanceConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" + ), + }; + } + + public static implicit operator PriceDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceDailyCreditAllowanceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter +{ + public override PriceDailyCreditAllowanceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceDailyCreditAllowanceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceDailyCreditAllowanceConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class PriceMeteredAllowance : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass>( + "cadence" + ); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for metered_allowance pricing + /// + public required PriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); + } + init { this._rawData.Set("metered_allowance_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 PriceMeteredAllowanceConversionRateConfig? 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.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; @@ -5819,34 +6968,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 +7007,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 +7029,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 +7039,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 +7059,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 +7075,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 +7180,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 +7256,7 @@ public JsonElement Json } } - public PriceMinimumConversionRateConfig( + public PriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6040,7 +7265,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig( + public PriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6049,7 +7274,7 @@ public PriceMinimumConversionRateConfig( this._element = element; } - public PriceMinimumConversionRateConfig(JsonElement element) + public PriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -6058,7 +7283,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 +7304,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7324,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7335,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6131,7 +7356,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 +7365,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7376,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6167,16 +7392,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 +7420,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 +7437,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 +7485,10 @@ JsonSerializerOptions 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 +7505,10 @@ JsonSerializerOptions 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 +7517,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 +7754,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +7810,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6571,8 +7819,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 +7942,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 +8030,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 +8051,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8071,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8082,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6858,7 +8112,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8123,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6919,10 +8173,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 +8184,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +8232,10 @@ JsonSerializerOptions 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 +8252,10 @@ JsonSerializerOptions 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 +8505,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8566,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7298,8 +8575,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 +8734,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 +8824,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 +8845,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8865,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8876,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7623,7 +8906,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8917,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7684,10 +8967,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 +8978,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9026,10 @@ JsonSerializerOptions 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 +9046,10 @@ JsonSerializerOptions 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..1a2ae5aa7 100644 --- a/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs +++ b/src/Orb/Models/Prices/PriceEvaluatePreviewEventsParams.cs @@ -28,8 +28,12 @@ namespace Orb.Models.Prices; /// /// Note that this is a POST endpoint rather than a GET endpoint because it /// employs a JSON body rather than query parameters. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class PriceEvaluatePreviewEventsParams : ParamsBase +public record class PriceEvaluatePreviewEventsParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -141,6 +145,8 @@ public IReadOnlyList? PriceEval public PriceEvaluatePreviewEventsParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParams( PriceEvaluatePreviewEventsParams priceEvaluatePreviewEventsParams ) @@ -148,6 +154,7 @@ PriceEvaluatePreviewEventsParams priceEvaluatePreviewEventsParams { this._rawBodyData = new(priceEvaluatePreviewEventsParams._rawBodyData); } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParams( IReadOnlyDictionary rawHeaderData, @@ -174,7 +181,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static PriceEvaluatePreviewEventsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -188,6 +195,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(PriceEvaluatePreviewEventsParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder( @@ -215,6 +250,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -308,8 +348,11 @@ public override void Validate() public Event() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Event(Event event_) : base(event_) { } +#pragma warning restore CS8618 public Event(IReadOnlyDictionary rawData) { @@ -398,6 +441,28 @@ public IReadOnlyList? GroupingKeys } } + /// + /// Optional overrides for parameterized billable metric parameters. If the metric + /// has parameter definitions and no overrides are provided, defaults will be used. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// New floating price request body params. /// @@ -432,16 +497,20 @@ public override void Validate() _ = this.ExternalPriceID; _ = this.Filter; _ = this.GroupingKeys; + _ = this.MetricParameterOverrides; this.Price?.Validate(); _ = this.PriceID; } public PriceEvaluatePreviewEventsParamsPriceEvaluation() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluation( PriceEvaluatePreviewEventsParamsPriceEvaluation priceEvaluatePreviewEventsParamsPriceEvaluation ) : base(priceEvaluatePreviewEventsParamsPriceEvaluation) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluation( IReadOnlyDictionary rawData @@ -530,7 +599,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 @@ -571,7 +641,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 @@ -612,7 +683,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 @@ -653,7 +725,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 @@ -694,7 +767,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 @@ -735,7 +809,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 @@ -776,7 +851,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 @@ -817,7 +893,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 @@ -858,7 +935,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 @@ -899,7 +977,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 @@ -940,7 +1019,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 @@ -981,7 +1061,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 +1070,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + 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 @@ -1242,7 +1365,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 +1418,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 +1439,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 +1460,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 +1481,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 +1505,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 +1526,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 +1547,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 +1570,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 +1593,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 +1616,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 +1639,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 +1662,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 +1685,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 +1708,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1599,7 +1731,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1622,7 +1754,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 +1777,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 +1800,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 +1823,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 +1846,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 +1869,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 +1895,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 +1918,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 +1941,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 +1964,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 +1987,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 +2010,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 +2033,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 +2057,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 +2108,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 +2131,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 +2154,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 +2177,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 +2188,39 @@ out PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput? value /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} /// ); /// /// @@ -2095,7 +2254,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 @@ -2187,8 +2347,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 +2373,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +2384,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, - /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent value) => {...}, + /// (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput value) => {...} /// ); /// /// @@ -2310,7 +2474,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 @@ -2356,7 +2527,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( @@ -2481,7 +2655,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( @@ -2547,17 +2725,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 +2744,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation _ => 27, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance _ => 28, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance _ => 29, + NewFloatingMinimumCompositePrice _ => 30, + PriceEvaluatePreviewEventsParamsPriceEvaluationPricePercent _ => 31, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceEventOutput _ => 32, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceConverter @@ -2600,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 } @@ -2622,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 } @@ -2644,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 } @@ -2667,12 +2884,10 @@ JsonSerializerOptions 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 +2904,10 @@ JsonSerializerOptions 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 +2924,10 @@ JsonSerializerOptions 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 +2945,10 @@ JsonSerializerOptions 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 +2965,10 @@ JsonSerializerOptions 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 +2986,10 @@ JsonSerializerOptions 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 +3006,10 @@ JsonSerializerOptions 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 +3027,10 @@ JsonSerializerOptions 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 +3048,10 @@ JsonSerializerOptions 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 +3068,10 @@ JsonSerializerOptions 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 +3089,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -2915,12 +3110,10 @@ JsonSerializerOptions 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 +3131,10 @@ JsonSerializerOptions 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 +3152,10 @@ JsonSerializerOptions 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 +3173,10 @@ JsonSerializerOptions 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 +3194,10 @@ JsonSerializerOptions 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 +3215,10 @@ JsonSerializerOptions 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 +3236,10 @@ JsonSerializerOptions 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 +3257,10 @@ JsonSerializerOptions 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 +3278,10 @@ JsonSerializerOptions 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 +3299,10 @@ JsonSerializerOptions 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 +3320,10 @@ JsonSerializerOptions 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 +3341,10 @@ JsonSerializerOptions 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 +3362,10 @@ JsonSerializerOptions 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 +3383,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 +3445,10 @@ JsonSerializerOptions 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 +3466,10 @@ JsonSerializerOptions 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 +3487,10 @@ JsonSerializerOptions 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 +3752,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +3813,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -3628,10 +3822,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 +3938,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 +4034,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 +4130,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 +4311,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 +4332,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +4352,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +4363,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4187,7 +4393,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +4404,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -4250,10 +4456,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 +4467,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +4515,10 @@ JsonSerializerOptions 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 +4535,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4587,6 +4802,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -4635,6 +4863,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4643,10 +4872,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThre this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -4841,12 +5073,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -4936,7 +5171,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 +5192,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5212,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5223,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5018,7 +5253,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5264,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5081,10 +5316,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5092,7 +5327,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -5127,12 +5375,10 @@ JsonSerializerOptions 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 +5395,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5418,6 +5662,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5466,6 +5723,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5474,10 +5732,13 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllo this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation ) : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -5672,12 +5933,15 @@ public override void Validate() public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( priceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -5767,7 +6031,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 +6052,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6072,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6083,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5849,7 +6113,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6124,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5912,10 +6176,10 @@ public override void Validate() public virtual bool Equals( PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -5923,7 +6187,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -5958,12 +6235,10 @@ JsonSerializerOptions 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 +6255,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6013,25 +6286,29 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum : JsonModel +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6051,31 +6328,31 @@ public required string Currency } /// - /// The id of the item the price will be associated with. + /// Configuration for daily_credit_allowance pricing /// - public required string ItemID + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig 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); } } /// @@ -6163,12 +6440,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig? ConversionRateConfig + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6245,6 +6522,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6271,9 +6561,14 @@ public override void Validate() { this.Cadence.Validate(); _ = this.Currency; + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -6288,31 +6583,35 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum() + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance( FrozenDictionary rawData ) { @@ -6320,8 +6619,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6329,20 +6628,25 @@ IReadOnlyDictionary rawData } } -class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumFromRaw - : IFromRawJson +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum FromRawUnchecked( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimum.FromRawUnchecked(rawData); + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowance.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter))] -public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceConverter) +)] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -6352,10 +6656,10 @@ public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Custom, } -sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadenceConverter - : JsonConverter +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence Read( + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6363,22 +6667,27 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual, + "annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual, "semi_annual" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual, - "monthly" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly, "quarterly" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly, "one_time" => - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime, - "custom" => PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom, - _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence)(-1), + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime, + "custom" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom, + _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence)( + -1 + ), }; } public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -6386,17 +6695,17 @@ JsonSerializerOptions options writer, value switch { - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Annual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Annual => "annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.SemiAnnual => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Monthly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Monthly => "monthly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Quarterly => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Quarterly => "quarterly", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.OneTime => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.OneTime => "one_time", - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumCadence.Custom => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) @@ -6408,75 +6717,895 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfigFromRaw + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw >) )] -public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string MinimumAmount + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("minimum_amount", value); } + init { this._rawData.Set("daily_allowance", value); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// Default per-unit credit rate for any usage not bucketed into a specified matrix_value /// - public bool? Prorated + public required string DefaultUnitAmount { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + 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 { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + 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< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + : 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() + { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigConverter) +)] +public record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig + : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + JsonElement element + ) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" + ), + }; + } + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig( + element + ); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceDailyCreditAllowanceConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance + : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum< + string, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence + > + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for metered_allowance pricing + /// + public required PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); + } + init { this._rawData.Set("metered_allowance_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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig? 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.MinimumAmount; - _ = this.Prorated; + this.Cadence.Validate(); + _ = this.Currency; + _ = 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.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig() { } + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance() + { + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); + } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance ) - : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig) { } + : base(priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance) { } +#pragma warning restore CS8618 - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance( FrozenDictionary rawData ) { @@ -6484,40 +7613,278 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig FromRawUnchecked( + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceFromRaw + : IFromRawJson +{ + /// + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowance.FromRawUnchecked( + rawData + ); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadenceConverter) +)] +public enum PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadenceConverter + : JsonConverter +{ + public override PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual, + "semi_annual" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly, + "quarterly" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly, + "one_time" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime, + "custom" => + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom, + _ => (PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence)(-1), + }; + } + + public override void Write( + Utf8JsonWriter writer, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Annual => + "annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.SemiAnnual => + "semi_annual", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Monthly => + "monthly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Quarterly => + "quarterly", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.OneTime => + "one_time", + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceCadence.Custom => + "custom", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); + } +} + +/// +/// Configuration for metered_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfigFromRaw + >) +)] +public sealed record class PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + : 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 PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig() + { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumMinimumConfig( - string minimumAmount + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + ) + : base( + priceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig + ) { } +#pragma warning restore CS8618 + + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData ) - : this() { - this.MinimumAmount = minimumAmount; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -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 +7902,7 @@ public JsonElement Json } } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -6544,7 +7911,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRate this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -6553,7 +7920,7 @@ public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRate this._element = element; } - public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + public PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -6564,7 +7931,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 +7952,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7972,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7983,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6637,7 +8004,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 +8013,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8024,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6673,16 +8040,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 +8068,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 +8087,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 +8135,10 @@ JsonSerializerOptions 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 +8155,10 @@ JsonSerializerOptions 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 +8167,7 @@ JsonSerializerOptions options } default: { - return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig( + return new PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig( element ); } @@ -6800,7 +8176,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMinimumConversionRateConfig value, + PriceEvaluatePreviewEventsParamsPriceEvaluationPriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -7042,6 +8418,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8474,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7093,10 +8483,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 +8630,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 +8733,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 +8754,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8774,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8785,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7419,7 +8815,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8826,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7482,10 +8878,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 +8889,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +8937,10 @@ JsonSerializerOptions 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 +8957,10 @@ JsonSerializerOptions 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 +9224,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9285,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7875,10 +9294,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 +9477,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 +9582,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 +9603,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9623,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9634,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8239,7 +9664,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9675,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8302,10 +9727,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 +9738,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9786,10 @@ JsonSerializerOptions 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 +9806,10 @@ JsonSerializerOptions 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..0d1fb8583 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionCreateParams.cs @@ -47,9 +47,9 @@ namespace Orb.Models.Subscriptions; /// the subscription being created. This is useful when a customer has prices that /// differ from the default prices for a specific plan. /// -/// This feature is only available for accounts that have migrated to -/// Subscription Overrides Version 2. You can find your Subscription Overrides Version -/// at the bottom of your [Plans page](https://app.withorb.com/plans) +/// <Note> This feature is only available for accounts that have migrated +/// to Subscription Overrides Version 2. You can find your Subscription Overrides +/// Version at the bottom of your [Plans page](https://app.withorb.com/plans) </Note> /// /// ### Adding Prices /// @@ -139,8 +139,8 @@ namespace Orb.Models.Subscriptions; /// /// ## Price overrides (DEPRECATED) /// -/// Price overrides are being phased out in favor adding/removing/replacing -/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) +/// <Note> Price overrides are being phased out in favor adding/removing/replacing +/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/create-subscription)) </Note> /// /// Price overrides are used to update some or all prices in a plan for the /// specific subscription being created. This is useful when a new customer has negotiated @@ -206,8 +206,12 @@ namespace Orb.Models.Subscriptions; /// /// ## Limits By default, Orb limits the number of subscriptions per customer /// to 100. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionCreateParams : ParamsBase +public record class SubscriptionCreateParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -734,11 +738,14 @@ public IReadOnlyList? UsageCustomerIds public SubscriptionCreateParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionCreateParams(SubscriptionCreateParams subscriptionCreateParams) : base(subscriptionCreateParams) { this._rawBodyData = new(subscriptionCreateParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionCreateParams( IReadOnlyDictionary rawHeaderData, @@ -765,7 +772,7 @@ FrozenDictionary rawBodyData } #pragma warning restore CS8618 - /// + /// public static SubscriptionCreateParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, @@ -779,6 +786,34 @@ IReadOnlyDictionary rawBodyData ); } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions + ); + + public virtual bool Equals(SubscriptionCreateParams? other) + { + if (other == null) + { + return false; + } + return this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); + } + public override System::Uri Url(ClientOptions options) { return new System::UriBuilder(options.BaseUrl.ToString().TrimEnd('/') + "/subscriptions") @@ -804,6 +839,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -812,14 +852,12 @@ public sealed record class AddAdjustment : JsonModel /// /// The definition of a new adjustment to create and add to the subscription. /// - public required global::Orb.Models.Subscriptions.Adjustment Adjustment + public required Adjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNotNullClass("adjustment"); } init { this._rawData.Set("adjustment", value); } } @@ -877,8 +915,11 @@ public override void Validate() public AddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddAdjustment(AddAdjustment addAdjustment) : base(addAdjustment) { } +#pragma warning restore CS8618 public AddAdjustment(IReadOnlyDictionary rawData) { @@ -900,7 +941,7 @@ public static AddAdjustment FromRawUnchecked(IReadOnlyDictionary r /// /// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.AdjustmentConverter))] +[JsonConverter(typeof(AdjustmentConverter))] public record class Adjustment : ModelBase { public object? Value { get; } = null; @@ -1002,7 +1043,7 @@ public Adjustment(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1023,7 +1064,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1044,7 +1085,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1065,7 +1106,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1086,7 +1127,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1106,7 +1147,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1117,11 +1158,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1160,7 +1201,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1171,11 +1212,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1199,23 +1240,15 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewPercentageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewPercentageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewUsageDiscount value - ) => new(value); + public static implicit operator Adjustment(NewUsageDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment( - NewAmountDiscount value - ) => new(value); + public static implicit operator Adjustment(NewAmountDiscount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment(NewMinimum value) => - new(value); + public static implicit operator Adjustment(NewMinimum value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Adjustment(NewMaximum value) => - new(value); + public static implicit operator Adjustment(NewMaximum value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1242,10 +1275,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Adjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Adjustment? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1253,12 +1286,28 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } -sealed class AdjustmentConverter : JsonConverter +sealed class AdjustmentConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Adjustment? Read( + public override Adjustment? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1287,12 +1336,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1309,12 +1356,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1331,12 +1376,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1350,12 +1393,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1369,12 +1410,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1383,14 +1422,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.Adjustment(element); + return new Adjustment(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Adjustment value, + Adjustment value, JsonSerializerOptions options ) { @@ -1477,6 +1516,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for this price. @@ -1508,12 +1569,12 @@ public long? PlanPhaseOrder /// /// New subscription price request body params. /// - public global::Orb.Models.Subscriptions.Price? Price + public Price? Price { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("price"); } init { this._rawData.Set("price", value); } } @@ -1557,6 +1618,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1566,8 +1628,11 @@ public override void Validate() public AddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public AddPrice(AddPrice addPrice) : base(addPrice) { } +#pragma warning restore CS8618 public AddPrice(IReadOnlyDictionary rawData) { @@ -1599,7 +1664,7 @@ public AddPrice FromRawUnchecked(IReadOnlyDictionary rawDat /// /// New subscription price request body params. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PriceConverter))] +[JsonConverter(typeof(PriceConverter))] public record class Price : ModelBase { public object? Value { get; } = null; @@ -1650,7 +1715,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 @@ -1691,7 +1757,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 @@ -1732,7 +1799,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 @@ -1773,7 +1841,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 @@ -1814,7 +1883,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 @@ -1855,7 +1925,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 @@ -1896,7 +1967,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 @@ -1939,7 +2011,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 @@ -1980,7 +2053,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 @@ -2021,7 +2095,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 @@ -2062,7 +2137,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 @@ -2104,7 +2180,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 +2189,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -2145,7 +2264,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 +2291,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 +2357,7 @@ public Price(NewSubscriptionMatrixWithAllocationPrice value, JsonElement? elemen this._element = element; } - public Price( - global::Orb.Models.Subscriptions.TieredWithProration value, - JsonElement? element = null - ) + public Price(TieredWithProration value, JsonElement? element = null) { this.Value = value; this._element = element; @@ -2279,10 +2393,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 +2441,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 +2465,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 +2486,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 +2507,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 +2530,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 +2549,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 +2572,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 +2595,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 +2618,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 +2641,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 +2664,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 +2687,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 +2710,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 +2733,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 +2756,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 +2779,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 +2800,22 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `global::Orb.Models.Subscriptions.TieredWithProration` + /// // `value` is of type `TieredWithProration` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] out global::Orb.Models.Subscriptions.TieredWithProration? value - ) + public bool TryPickTieredWithProration([NotNullWhen(true)] out TieredWithProration? value) { - value = this.Value as global::Orb.Models.Subscriptions.TieredWithProration; + value = this.Value as TieredWithProration; return value != null; } @@ -2713,7 +2823,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 +2846,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 +2869,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 +2892,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 +2915,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 +2936,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 +2961,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 +2984,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 +3007,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 +3030,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 +3053,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 +3076,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 +3097,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 +3164,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 +3185,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 +3239,39 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3154,7 +3280,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 +3291,25 @@ public void Switch( System::Action newSubscriptionPackageWithAllocation, System::Action newSubscriptionUnitWithPercent, System::Action newSubscriptionMatrixWithAllocation, - System::Action tieredWithProration, + System::Action tieredWithProration, System::Action newSubscriptionUnitWithProration, System::Action newSubscriptionGroupedAllocation, System::Action newSubscriptionBulkWithProration, System::Action newSubscriptionGroupedWithProratedMinimum, System::Action newSubscriptionGroupedWithMeteredMinimum, - System::Action groupedWithMinMaxThresholds, + System::Action groupedWithMinMaxThresholds, System::Action newSubscriptionMatrixWithDisplayName, System::Action newSubscriptionGroupedTieredPackage, System::Action newSubscriptionMaxGroupTieredPackage, System::Action newSubscriptionScalableMatrixWithUnitPricing, System::Action newSubscriptionScalableMatrixWithTieredPricing, System::Action newSubscriptionCumulativeGroupedBulk, - System::Action cumulativeGroupedAllocation, - System::Action minimum, + System::Action cumulativeGroupedAllocation, + System::Action dailyCreditAllowance, + System::Action meteredAllowance, System::Action newSubscriptionMinimumComposite, - System::Action percent, - System::Action eventOutput + System::Action percent, + System::Action eventOutput ) { switch (this.Value) @@ -3196,7 +3323,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 +3356,7 @@ public void Switch( case NewSubscriptionMatrixWithAllocationPrice value: newSubscriptionMatrixWithAllocation(value); break; - case global::Orb.Models.Subscriptions.TieredWithProration value: + case TieredWithProration value: tieredWithProration(value); break; case NewSubscriptionUnitWithProrationPrice value: @@ -3247,7 +3374,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 +3395,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 +3422,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +3433,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.BulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.TieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value) => {...}, - /// (global::Orb.Models.Subscriptions.Minimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (global::Orb.Models.Subscriptions.Percent value) => {...}, - /// (global::Orb.Models.Subscriptions.EventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (BulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (TieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (GroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (CumulativeGroupedAllocation value) => {...}, + /// (DailyCreditAllowance value) => {...}, + /// (MeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (Percent value) => {...}, + /// (EventOutput value) => {...} /// ); /// /// @@ -3343,7 +3474,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 +3497,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice, T > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, + System::Func tieredWithProration, System::Func newSubscriptionUnitWithProration, System::Func newSubscriptionGroupedAllocation, System::Func newSubscriptionBulkWithProration, @@ -3378,10 +3509,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 +3534,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 +3547,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 +3565,7 @@ public T Match( NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( value ), - global::Orb.Models.Subscriptions.TieredWithProration value => tieredWithProration( - value - ), + TieredWithProration value => tieredWithProration(value), NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), @@ -3449,8 +3573,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 +3590,99 @@ 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(TieredWithProration value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionUnitWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedAllocationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionBulkWithProrationPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithProratedMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedWithMeteredMinimumPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds value - ) => new(value); + public static implicit operator Price(GroupedWithMinMaxThresholds value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMatrixWithDisplayNamePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionGroupedTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionMaxGroupTieredPackagePrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithUnitPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( + public static implicit operator Price( NewSubscriptionScalableMatrixWithTieredPricingPrice value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); + public static implicit operator Price(NewSubscriptionCumulativeGroupedBulkPrice value) => + new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation value - ) => new(value); + public static implicit operator Price(CumulativeGroupedAllocation value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Price( - global::Orb.Models.Subscriptions.Minimum value - ) => new(value); + public static implicit operator Price(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 @@ -3659,17 +3738,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 +3757,56 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + BulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + TieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + GroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + CumulativeGroupedAllocation _ => 27, + DailyCreditAllowance _ => 28, + MeteredAllowance _ => 29, + NewSubscriptionMinimumCompositePrice _ => 30, + Percent _ => 31, + EventOutput _ => 32, + _ => -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 +3835,10 @@ JsonSerializerOptions 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 +3855,10 @@ JsonSerializerOptions 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 +3875,10 @@ JsonSerializerOptions 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 +3889,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 +3915,10 @@ JsonSerializerOptions 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 +3935,10 @@ JsonSerializerOptions 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 +3956,10 @@ JsonSerializerOptions 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 +3977,10 @@ JsonSerializerOptions 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 +3998,10 @@ JsonSerializerOptions 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 +4019,10 @@ JsonSerializerOptions 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 +4040,10 @@ JsonSerializerOptions 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 +4061,10 @@ JsonSerializerOptions 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 +4082,10 @@ JsonSerializerOptions 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 +4103,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4022,19 +4117,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 +4144,10 @@ JsonSerializerOptions 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 +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 } @@ -4098,12 +4186,10 @@ JsonSerializerOptions 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 +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 } @@ -4144,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 } @@ -4160,19 +4242,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 +4269,10 @@ JsonSerializerOptions 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 +4290,10 @@ JsonSerializerOptions 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 +4311,10 @@ JsonSerializerOptions 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 +4332,10 @@ JsonSerializerOptions 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 +4353,10 @@ JsonSerializerOptions 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 +4374,10 @@ JsonSerializerOptions 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 +4388,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 } @@ -4374,12 +4455,10 @@ JsonSerializerOptions 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 +4469,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 +4486,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 +4501,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 +4531,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 +4639,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 +4733,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4808,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4752,8 +4818,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 +4839,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 +4881,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 +4912,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 +4931,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 +4940,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 +4989,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 +5008,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 +5063,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 +5082,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 +5096,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 +5117,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 +5127,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 +5158,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 +5197,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 +5218,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5238,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5249,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5236,7 +5279,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5290,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5268,13 +5311,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 +5338,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 +5349,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 +5396,10 @@ JsonSerializerOptions 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 +5416,10 @@ JsonSerializerOptions 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 +5428,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.ConversionRateConfig(element); + return new ConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.ConversionRateConfig value, + ConversionRateConfig value, JsonSerializerOptions options ) { @@ -5394,28 +5443,20 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProration, - global::Orb.Models.Subscriptions.TieredWithProrationFromRaw - >) -)] +[JsonConverter(typeof(JsonModelConverter))] public sealed record class TieredWithProration : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.TieredWithProrationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass< - ApiEnum - >("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } @@ -5462,12 +5503,12 @@ public required string Name /// /// Configuration for tiered_with_proration pricing /// - public required global::Orb.Models.Subscriptions.TieredWithProrationConfig TieredWithProrationConfig + public required TieredWithProrationConfig TieredWithProrationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "tiered_with_proration_config" ); } @@ -5533,12 +5574,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? ConversionRateConfig + public TieredWithProrationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -5629,6 +5670,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5691,6 +5745,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5700,10 +5755,11 @@ public TieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } - public TieredWithProration( - global::Orb.Models.Subscriptions.TieredWithProration tieredWithProration - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProration(TieredWithProration tieredWithProration) : base(tieredWithProration) { } +#pragma warning restore CS8618 public TieredWithProration(IReadOnlyDictionary rawData) { @@ -5720,8 +5776,8 @@ public TieredWithProration(IReadOnlyDictionary rawData) } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( + /// + public static TieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5729,19 +5785,17 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationFromRaw - : IFromRawJson +class TieredWithProrationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProration FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProration.FromRawUnchecked(rawData); + public TieredWithProration FromRawUnchecked(IReadOnlyDictionary rawData) => + TieredWithProration.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.TieredWithProrationCadenceConverter))] +[JsonConverter(typeof(TieredWithProrationCadenceConverter))] public enum TieredWithProrationCadence { Annual, @@ -5752,10 +5806,9 @@ public enum TieredWithProrationCadence Custom, } -sealed class TieredWithProrationCadenceConverter - : JsonConverter +sealed class TieredWithProrationCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationCadence Read( + public override TieredWithProrationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -5763,19 +5816,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Annual, - "semi_annual" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.SemiAnnual, - "monthly" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Monthly, - "quarterly" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Quarterly, - "one_time" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.OneTime, - "custom" => global::Orb.Models.Subscriptions.TieredWithProrationCadence.Custom, - _ => (global::Orb.Models.Subscriptions.TieredWithProrationCadence)(-1), + "annual" => TieredWithProrationCadence.Annual, + "semi_annual" => TieredWithProrationCadence.SemiAnnual, + "monthly" => TieredWithProrationCadence.Monthly, + "quarterly" => TieredWithProrationCadence.Quarterly, + "one_time" => TieredWithProrationCadence.OneTime, + "custom" => TieredWithProrationCadence.Custom, + _ => (TieredWithProrationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationCadence value, + TieredWithProrationCadence value, JsonSerializerOptions options ) { @@ -5783,14 +5836,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Annual => "annual", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Monthly => "monthly", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.OneTime => "one_time", - global::Orb.Models.Subscriptions.TieredWithProrationCadence.Custom => "custom", + TieredWithProrationCadence.Annual => "annual", + TieredWithProrationCadence.SemiAnnual => "semi_annual", + TieredWithProrationCadence.Monthly => "monthly", + TieredWithProrationCadence.Quarterly => "quarterly", + TieredWithProrationCadence.OneTime => "one_time", + TieredWithProrationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -5804,10 +5855,7 @@ JsonSerializerOptions options /// Configuration for tiered_with_proration pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfig, - global::Orb.Models.Subscriptions.TieredWithProrationConfigFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfig : JsonModel { @@ -5815,20 +5863,21 @@ public sealed record class TieredWithProrationConfig : JsonModel /// Tiers for rating based on total usage quantities into the specified tier /// with proration /// - public required IReadOnlyList Tiers + public required IReadOnlyList Tiers { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct< - ImmutableArray - >("tiers"); + return this._rawData.GetNotNullStruct>( + "tiers" + ); } init { - this._rawData.Set< - ImmutableArray - >("tiers", ImmutableArray.ToImmutableArray(value)); + this._rawData.Set>( + "tiers", + ImmutableArray.ToImmutableArray(value) + ); } } @@ -5843,10 +5892,11 @@ public override void Validate() public TieredWithProrationConfig() { } - public TieredWithProrationConfig( - global::Orb.Models.Subscriptions.TieredWithProrationConfig tieredWithProrationConfig - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public TieredWithProrationConfig(TieredWithProrationConfig tieredWithProrationConfig) : base(tieredWithProrationConfig) { } +#pragma warning restore CS8618 public TieredWithProrationConfig(IReadOnlyDictionary rawData) { @@ -5861,8 +5911,8 @@ public TieredWithProrationConfig(IReadOnlyDictionary rawDat } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + /// + public static TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5870,32 +5920,26 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public TieredWithProrationConfig( - IReadOnlyList tiers - ) + public TieredWithProrationConfig(IReadOnlyList tiers) : this() { this.Tiers = tiers; } } -class TieredWithProrationConfigFromRaw - : IFromRawJson +class TieredWithProrationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfig FromRawUnchecked( + public TieredWithProrationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfig.FromRawUnchecked(rawData); + ) => TieredWithProrationConfig.FromRawUnchecked(rawData); } /// /// Configuration for a single tiered with proration tier /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier, - global::Orb.Models.Subscriptions.TieredWithProrationConfigTierFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class TieredWithProrationConfigTier : JsonModel { @@ -5934,10 +5978,13 @@ public override void Validate() public TieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public TieredWithProrationConfigTier( - global::Orb.Models.Subscriptions.TieredWithProrationConfigTier tieredWithProrationConfigTier + TieredWithProrationConfigTier tieredWithProrationConfigTier ) : base(tieredWithProrationConfigTier) { } +#pragma warning restore CS8618 public TieredWithProrationConfigTier(IReadOnlyDictionary rawData) { @@ -5952,8 +5999,8 @@ public TieredWithProrationConfigTier(IReadOnlyDictionary ra } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + /// + public static TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -5961,18 +6008,15 @@ IReadOnlyDictionary rawData } } -class TieredWithProrationConfigTierFromRaw - : IFromRawJson +class TieredWithProrationConfigTierFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.TieredWithProrationConfigTier FromRawUnchecked( + public TieredWithProrationConfigTier FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.TieredWithProrationConfigTier.FromRawUnchecked(rawData); + ) => TieredWithProrationConfigTier.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfigConverter) -)] +[JsonConverter(typeof(TieredWithProrationConversionRateConfigConverter))] public record class TieredWithProrationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6017,7 +6061,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 +6082,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6102,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6113,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6099,7 +6143,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6154,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6131,11 +6175,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( + public static implicit operator TieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6160,12 +6204,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(TieredWithProrationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6173,13 +6215,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class TieredWithProrationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig? Read( + public override TieredWithProrationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6208,12 +6263,10 @@ JsonSerializerOptions 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 +6283,10 @@ JsonSerializerOptions 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 +6295,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig( - element - ); + return new TieredWithProrationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.TieredWithProrationConversionRateConfig value, + TieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -6262,26 +6311,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class GroupedWithMinMaxThresholds : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -6290,12 +6333,12 @@ public required ApiEnum< /// /// Configuration for grouped_with_min_max_thresholds pricing /// - public required global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig + public required GroupedWithMinMaxThresholdsConfig GroupedWithMinMaxThresholdsConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "grouped_with_min_max_thresholds_config" ); } @@ -6400,12 +6443,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig + public GroupedWithMinMaxThresholdsConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -6496,6 +6539,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6558,6 +6614,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6567,10 +6624,11 @@ public GroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } - public GroupedWithMinMaxThresholds( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds groupedWithMinMaxThresholds - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public GroupedWithMinMaxThresholds(GroupedWithMinMaxThresholds groupedWithMinMaxThresholds) : base(groupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -6587,8 +6645,8 @@ public GroupedWithMinMaxThresholds(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6596,21 +6654,18 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds FromRawUnchecked( + public GroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); + ) => GroupedWithMinMaxThresholds.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadenceConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsCadenceConverter))] public enum GroupedWithMinMaxThresholdsCadence { Annual, @@ -6622,9 +6677,9 @@ public enum GroupedWithMinMaxThresholdsCadence } sealed class GroupedWithMinMaxThresholdsCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence Read( + public override GroupedWithMinMaxThresholdsCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -6632,35 +6687,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Annual, - "semi_annual" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Subscriptions - .GroupedWithMinMaxThresholdsCadence - .OneTime, - "custom" => global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Custom, - _ => (global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence)(-1), + "annual" => GroupedWithMinMaxThresholdsCadence.Annual, + "semi_annual" => GroupedWithMinMaxThresholdsCadence.SemiAnnual, + "monthly" => GroupedWithMinMaxThresholdsCadence.Monthly, + "quarterly" => GroupedWithMinMaxThresholdsCadence.Quarterly, + "one_time" => GroupedWithMinMaxThresholdsCadence.OneTime, + "custom" => GroupedWithMinMaxThresholdsCadence.Custom, + _ => (GroupedWithMinMaxThresholdsCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence value, + GroupedWithMinMaxThresholdsCadence value, JsonSerializerOptions options ) { @@ -6668,18 +6707,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Annual => - "annual", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Monthly => - "monthly", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.OneTime => - "one_time", - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsCadence.Custom => - "custom", + GroupedWithMinMaxThresholdsCadence.Annual => "annual", + GroupedWithMinMaxThresholdsCadence.SemiAnnual => "semi_annual", + GroupedWithMinMaxThresholdsCadence.Monthly => "monthly", + GroupedWithMinMaxThresholdsCadence.Quarterly => "quarterly", + GroupedWithMinMaxThresholdsCadence.OneTime => "one_time", + GroupedWithMinMaxThresholdsCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -6694,8 +6727,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfigFromRaw + GroupedWithMinMaxThresholdsConfig, + GroupedWithMinMaxThresholdsConfigFromRaw >) )] public sealed record class GroupedWithMinMaxThresholdsConfig : JsonModel @@ -6763,10 +6796,13 @@ public override void Validate() public GroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public GroupedWithMinMaxThresholdsConfig( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig + GroupedWithMinMaxThresholdsConfig groupedWithMinMaxThresholdsConfig ) : base(groupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary rawData) { @@ -6781,8 +6817,8 @@ public GroupedWithMinMaxThresholdsConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -6790,21 +6826,15 @@ IReadOnlyDictionary rawData } } -class GroupedWithMinMaxThresholdsConfigFromRaw - : IFromRawJson +class GroupedWithMinMaxThresholdsConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig FromRawUnchecked( + public GroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConfig.FromRawUnchecked( - rawData - ); + ) => GroupedWithMinMaxThresholdsConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfigConverter) -)] +[JsonConverter(typeof(GroupedWithMinMaxThresholdsConversionRateConfigConverter))] public record class GroupedWithMinMaxThresholdsConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -6849,7 +6879,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 +6900,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6920,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6931,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6931,7 +6961,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6972,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6963,11 +6993,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( + public static implicit operator GroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -6992,12 +7022,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(GroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7005,13 +7033,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class GroupedWithMinMaxThresholdsConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig? Read( + public override GroupedWithMinMaxThresholdsConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7040,12 +7081,10 @@ JsonSerializerOptions 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 +7101,10 @@ JsonSerializerOptions 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 +7113,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig( - element - ); + return new GroupedWithMinMaxThresholdsConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.GroupedWithMinMaxThresholdsConversionRateConfig value, + GroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -7094,26 +7129,20 @@ JsonSerializerOptions options } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class CumulativeGroupedAllocation : JsonModel { /// /// The cadence to bill for this price on. /// - public required ApiEnum< - string, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence - > Cadence + public required ApiEnum Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -7122,12 +7151,12 @@ public required ApiEnum< /// /// Configuration for cumulative_grouped_allocation pricing /// - public required global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig + public required CumulativeGroupedAllocationConfig CumulativeGroupedAllocationConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( + return this._rawData.GetNotNullClass( "cumulative_grouped_allocation_config" ); } @@ -7232,12 +7261,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig + public CumulativeGroupedAllocationConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7328,6 +7357,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7390,6 +7432,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7399,10 +7442,11 @@ public CumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } - public CumulativeGroupedAllocation( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocation cumulativeGroupedAllocation - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public CumulativeGroupedAllocation(CumulativeGroupedAllocation cumulativeGroupedAllocation) : base(cumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -7419,8 +7463,8 @@ public CumulativeGroupedAllocation(IReadOnlyDictionary rawD } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + /// + public static CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7428,21 +7472,18 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationFromRaw - : IFromRawJson +class CumulativeGroupedAllocationFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocation FromRawUnchecked( + public CumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.CumulativeGroupedAllocation.FromRawUnchecked(rawData); + ) => CumulativeGroupedAllocation.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadenceConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationCadenceConverter))] public enum CumulativeGroupedAllocationCadence { Annual, @@ -7454,9 +7495,9 @@ public enum CumulativeGroupedAllocationCadence } sealed class CumulativeGroupedAllocationCadenceConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence Read( + public override CumulativeGroupedAllocationCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7464,35 +7505,19 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Annual, - "semi_annual" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .SemiAnnual, - "monthly" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .Monthly, - "quarterly" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .Quarterly, - "one_time" => global::Orb - .Models - .Subscriptions - .CumulativeGroupedAllocationCadence - .OneTime, - "custom" => global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Custom, - _ => (global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence)(-1), + "annual" => CumulativeGroupedAllocationCadence.Annual, + "semi_annual" => CumulativeGroupedAllocationCadence.SemiAnnual, + "monthly" => CumulativeGroupedAllocationCadence.Monthly, + "quarterly" => CumulativeGroupedAllocationCadence.Quarterly, + "one_time" => CumulativeGroupedAllocationCadence.OneTime, + "custom" => CumulativeGroupedAllocationCadence.Custom, + _ => (CumulativeGroupedAllocationCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence value, + CumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -7500,18 +7525,12 @@ JsonSerializerOptions options writer, value switch { - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Annual => - "annual", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.SemiAnnual => - "semi_annual", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Monthly => - "monthly", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Quarterly => - "quarterly", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.OneTime => - "one_time", - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationCadence.Custom => - "custom", + CumulativeGroupedAllocationCadence.Annual => "annual", + CumulativeGroupedAllocationCadence.SemiAnnual => "semi_annual", + CumulativeGroupedAllocationCadence.Monthly => "monthly", + CumulativeGroupedAllocationCadence.Quarterly => "quarterly", + CumulativeGroupedAllocationCadence.OneTime => "one_time", + CumulativeGroupedAllocationCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -7526,8 +7545,8 @@ JsonSerializerOptions options /// [JsonConverter( typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfigFromRaw + CumulativeGroupedAllocationConfig, + CumulativeGroupedAllocationConfigFromRaw >) )] public sealed record class CumulativeGroupedAllocationConfig : JsonModel @@ -7595,10 +7614,13 @@ public override void Validate() public CumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public CumulativeGroupedAllocationConfig( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig + CumulativeGroupedAllocationConfig cumulativeGroupedAllocationConfig ) : base(cumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public CumulativeGroupedAllocationConfig(IReadOnlyDictionary rawData) { @@ -7613,8 +7635,8 @@ public CumulativeGroupedAllocationConfig(IReadOnlyDictionary - public static global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -7622,21 +7644,15 @@ IReadOnlyDictionary rawData } } -class CumulativeGroupedAllocationConfigFromRaw - : IFromRawJson +class CumulativeGroupedAllocationConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig FromRawUnchecked( + public CumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConfig.FromRawUnchecked( - rawData - ); + ) => CumulativeGroupedAllocationConfig.FromRawUnchecked(rawData); } -[JsonConverter( - typeof(global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfigConverter) -)] +[JsonConverter(typeof(CumulativeGroupedAllocationConversionRateConfigConverter))] public record class CumulativeGroupedAllocationConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -7681,7 +7697,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 +7718,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7738,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7749,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7763,7 +7779,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7790,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7795,11 +7811,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( + public static implicit operator CumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -7824,12 +7840,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals( - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(CumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7837,13 +7851,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class CumulativeGroupedAllocationConversionRateConfigConverter - : JsonConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig? Read( + public override CumulativeGroupedAllocationConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -7872,12 +7899,10 @@ JsonSerializerOptions 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 +7919,10 @@ JsonSerializerOptions 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 +7931,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig( - element - ); + return new CumulativeGroupedAllocationConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.CumulativeGroupedAllocationConversionRateConfig value, + CumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -7925,53 +7946,50 @@ JsonSerializerOptions options } } -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.Minimum, - global::Orb.Models.Subscriptions.MinimumFromRaw - >) -)] -public sealed record class Minimum : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class 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>("cadence"); + return this._rawData.GetNotNullClass>( + "cadence" + ); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for daily_credit_allowance pricing /// - public required string ItemID + public required DailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("daily_credit_allowance_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 +8077,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public MinimumConversionRateConfig? ConversionRateConfig + public DailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8155,6 +8173,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8225,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -8212,35 +8248,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Minimum() + public DailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public Minimum(global::Orb.Models.Subscriptions.Minimum minimum) - : base(minimum) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowance(DailyCreditAllowance dailyCreditAllowance) + : base(dailyCreditAllowance) { } +#pragma warning restore CS8618 - public Minimum(IReadOnlyDictionary rawData) + public DailyCreditAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Minimum(FrozenDictionary rawData) + DailyCreditAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( + /// + public static DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8248,19 +8288,19 @@ IReadOnlyDictionary rawData } } -class MinimumFromRaw : IFromRawJson +class DailyCreditAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Minimum FromRawUnchecked( + public DailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Minimum.FromRawUnchecked(rawData); + ) => DailyCreditAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(MinimumCadenceConverter))] -public enum MinimumCadence +[JsonConverter(typeof(DailyCreditAllowanceCadenceConverter))] +public enum DailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -8270,9 +8310,9 @@ public enum MinimumCadence Custom, } -sealed class MinimumCadenceConverter : JsonConverter +sealed class DailyCreditAllowanceCadenceConverter : JsonConverter { - public override MinimumCadence Read( + public override DailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8280,19 +8320,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" => 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, - MinimumCadence value, + DailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -8300,12 +8340,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", + 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)) ), @@ -8316,101 +8356,226 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.MinimumConfig, - global::Orb.Models.Subscriptions.MinimumConfigFromRaw - >) + typeof(JsonModelConverter) )] -public sealed record class MinimumConfig : JsonModel +public sealed record class DailyCreditAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string MinimumAmount + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("minimum_amount", 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); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// One or two event property values to evaluate matrix groups by /// - public bool? Prorated + public required IReadOnlyList Dimensions { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullStruct>("dimensions"); } init { - if (value == null) - { - return; - } - - this._rawData.Set("prorated", value); + 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>("matrix_values"); + } + init + { + this._rawData.Set>( + "matrix_values", + ImmutableArray.ToImmutableArray(value) + ); + } + } + + /// public override void Validate() { - _ = this.MinimumAmount; - _ = this.Prorated; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public MinimumConfig() { } + public DailyCreditAllowanceConfig() { } - public MinimumConfig(global::Orb.Models.Subscriptions.MinimumConfig minimumConfig) - : base(minimumConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public DailyCreditAllowanceConfig(DailyCreditAllowanceConfig dailyCreditAllowanceConfig) + : base(dailyCreditAllowanceConfig) { } +#pragma warning restore CS8618 - public MinimumConfig(IReadOnlyDictionary rawData) + public DailyCreditAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - MinimumConfig(FrozenDictionary rawData) + DailyCreditAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.MinimumConfig 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))] +public sealed record class MatrixValue : 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 MatrixValue() { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public MinimumConfig(string minimumAmount) - : this() + 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) { - this.MinimumAmount = minimumAmount; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class MinimumConfigFromRaw : IFromRawJson +class MatrixValueFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.MinimumConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.MinimumConfig.FromRawUnchecked(rawData); + public MatrixValue FromRawUnchecked(IReadOnlyDictionary rawData) => + MatrixValue.FromRawUnchecked(rawData); } -[JsonConverter(typeof(MinimumConversionRateConfigConverter))] -public record class MinimumConversionRateConfig : ModelBase +[JsonConverter(typeof(DailyCreditAllowanceConversionRateConfigConverter))] +public record class DailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8427,7 +8592,7 @@ public JsonElement Json } } - public MinimumConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8436,7 +8601,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig( + public DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8445,7 +8610,7 @@ public MinimumConversionRateConfig( this._element = element; } - public MinimumConversionRateConfig(JsonElement element) + public DailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -8454,7 +8619,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 +8640,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8660,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8671,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8527,7 +8692,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of MinimumConversionRateConfig" + "Data did not match any variant of DailyCreditAllowanceConversionRateConfig" ); } } @@ -8536,7 +8701,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8712,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8563,16 +8728,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 DailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator MinimumConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator MinimumConversionRateConfig( + public static implicit operator DailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8591,16 +8756,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 DailyCreditAllowanceConversionRateConfig" ); } 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(DailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8608,12 +8773,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 DailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override MinimumConversionRateConfig? Read( + public override DailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8642,12 +8821,10 @@ JsonSerializerOptions 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 +8841,10 @@ JsonSerializerOptions 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 +8853,14 @@ JsonSerializerOptions options } default: { - return new MinimumConversionRateConfig(element); + return new DailyCreditAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - MinimumConversionRateConfig value, + DailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -8693,25 +8868,20 @@ 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 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); } } @@ -8730,44 +8900,44 @@ public required string ItemID } /// - /// The pricing model type + /// Configuration for metered_allowance pricing /// - public JsonElement ModelType + public required MeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("metered_allowance_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 percent pricing + /// The name of the price. /// - public required global::Orb.Models.Subscriptions.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); } } /// @@ -8829,12 +8999,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 MeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8925,6 +9095,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -8965,12 +9148,17 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -8982,35 +9170,39 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public Percent() + public MeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public Percent(global::Orb.Models.Subscriptions.Percent percent) - : base(percent) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowance(MeteredAllowance meteredAllowance) + : base(meteredAllowance) { } +#pragma warning restore CS8618 - public Percent(IReadOnlyDictionary rawData) + public MeteredAllowance(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - Percent(FrozenDictionary rawData) + MeteredAllowance(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.Percent FromRawUnchecked( + /// + public static MeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9018,19 +9210,18 @@ IReadOnlyDictionary rawData } } -class PercentFromRaw : IFromRawJson +class MeteredAllowanceFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.Percent FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.Percent.FromRawUnchecked(rawData); + public MeteredAllowance FromRawUnchecked(IReadOnlyDictionary rawData) => + MeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentCadenceConverter))] -public enum PercentCadence +[JsonConverter(typeof(MeteredAllowanceCadenceConverter))] +public enum MeteredAllowanceCadence { Annual, SemiAnnual, @@ -9040,10 +9231,9 @@ public enum PercentCadence Custom, } -sealed class PercentCadenceConverter - : JsonConverter +sealed class MeteredAllowanceCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentCadence Read( + public override MeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9051,19 +9241,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" => 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.PercentCadence value, + MeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -9071,12 +9261,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", + 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)) ), @@ -9087,79 +9277,161 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for metered_allowance pricing /// -[JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.PercentConfig, - global::Orb.Models.Subscriptions.PercentConfigFromRaw - >) -)] -public sealed record class PercentConfig : JsonModel +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class MeteredAllowanceConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// 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 double Percent + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + 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); } - init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public PercentConfig() { } + public MeteredAllowanceConfig() { } - public PercentConfig(global::Orb.Models.Subscriptions.PercentConfig percentConfig) - : base(percentConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public MeteredAllowanceConfig(MeteredAllowanceConfig meteredAllowanceConfig) + : base(meteredAllowanceConfig) { } +#pragma warning restore CS8618 - public PercentConfig(IReadOnlyDictionary rawData) + public MeteredAllowanceConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - PercentConfig(FrozenDictionary rawData) + MeteredAllowanceConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + /// + public static MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public PercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class PercentConfigFromRaw : IFromRawJson +class MeteredAllowanceConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.PercentConfig FromRawUnchecked( + public MeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.PercentConfig.FromRawUnchecked(rawData); + ) => MeteredAllowanceConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.PercentConversionRateConfigConverter))] -public record class PercentConversionRateConfig : ModelBase +[JsonConverter(typeof(MeteredAllowanceConversionRateConfigConverter))] +public record class MeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9176,7 +9448,7 @@ public JsonElement Json } } - public PercentConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9185,7 +9457,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig( + public MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9194,7 +9466,7 @@ public PercentConversionRateConfig( this._element = element; } - public PercentConversionRateConfig(JsonElement element) + public MeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -9203,7 +9475,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 +9496,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9516,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9527,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9276,7 +9548,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of PercentConversionRateConfig" + "Data did not match any variant of MeteredAllowanceConversionRateConfig" ); } } @@ -9285,7 +9557,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9568,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9312,16 +9584,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 MeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.PercentConversionRateConfig( + public static implicit operator MeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9340,16 +9612,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 MeteredAllowanceConversionRateConfig" ); } 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(MeteredAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -9357,13 +9629,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 MeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override global::Orb.Models.Subscriptions.PercentConversionRateConfig? Read( + public override MeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9392,12 +9677,10 @@ JsonSerializerOptions 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 +9697,10 @@ JsonSerializerOptions 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 +9709,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.PercentConversionRateConfig(element); + return new MeteredAllowanceConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.PercentConversionRateConfig value, + MeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9443,44 +9724,22 @@ 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 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); } } - /// - /// Configuration for event_output pricing - /// - public required global::Orb.Models.Subscriptions.EventOutputConfig EventOutputConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -9520,6 +9779,19 @@ public required string Name init { this._rawData.Set("name", value); } } + /// + /// Configuration for percent pricing + /// + public required PercentConfig PercentConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("percent_config"); + } + init { this._rawData.Set("percent_config", value); } + } + /// /// The id of the billable metric for the price. Only needed if the price is usage-based. /// @@ -9579,12 +9851,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 PercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9675,6 +9947,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,18 +9999,13 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + 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(); @@ -9737,55 +10017,56 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public EventOutput() + public Percent() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public EventOutput(global::Orb.Models.Subscriptions.EventOutput eventOutput) - : base(eventOutput) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public Percent(Percent percent) + : base(percent) { } +#pragma warning restore CS8618 - public EventOutput(IReadOnlyDictionary rawData) + public Percent(IReadOnlyDictionary rawData) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutput(FrozenDictionary rawData) + Percent(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static Percent FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class EventOutputFromRaw : IFromRawJson +class PercentFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutput FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutput.FromRawUnchecked(rawData); + public Percent FromRawUnchecked(IReadOnlyDictionary rawData) => + Percent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputCadenceConverter))] -public enum EventOutputCadence +[JsonConverter(typeof(PercentCadenceConverter))] +public enum PercentCadence { Annual, SemiAnnual, @@ -9795,10 +10076,9 @@ public enum EventOutputCadence Custom, } -sealed class EventOutputCadenceConverter - : JsonConverter +sealed class PercentCadenceConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputCadence Read( + public override PercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9806,19 +10086,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" => PercentCadence.Annual, + "semi_annual" => PercentCadence.SemiAnnual, + "monthly" => PercentCadence.Monthly, + "quarterly" => PercentCadence.Quarterly, + "one_time" => PercentCadence.OneTime, + "custom" => PercentCadence.Custom, + _ => (PercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputCadence value, + PercentCadence value, JsonSerializerOptions options ) { @@ -9826,12 +10106,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", + 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)) ), @@ -9842,110 +10122,74 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for percent 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 PercentConfig : 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. + /// What percent of the component subtotals to charge /// - public string? GroupingKey + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullStruct("percent"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + _ = this.Percent; } - public EventOutputConfig() { } + public PercentConfig() { } - public EventOutputConfig(global::Orb.Models.Subscriptions.EventOutputConfig eventOutputConfig) - : base(eventOutputConfig) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PercentConfig(PercentConfig percentConfig) + : base(percentConfig) { } +#pragma warning restore CS8618 - public EventOutputConfig(IReadOnlyDictionary rawData) + public PercentConfig(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - EventOutputConfig(FrozenDictionary rawData) + PercentConfig(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + public static PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } [SetsRequiredMembers] - public EventOutputConfig(string unitRatingKey) + public PercentConfig(double percent) : this() { - this.UnitRatingKey = unitRatingKey; + this.Percent = percent; } } -class EventOutputConfigFromRaw : IFromRawJson +class PercentConfigFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.EventOutputConfig FromRawUnchecked( - IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.EventOutputConfig.FromRawUnchecked(rawData); + public PercentConfig FromRawUnchecked(IReadOnlyDictionary rawData) => + PercentConfig.FromRawUnchecked(rawData); } -[JsonConverter(typeof(global::Orb.Models.Subscriptions.EventOutputConversionRateConfigConverter))] -public record class EventOutputConversionRateConfig : ModelBase +[JsonConverter(typeof(PercentConversionRateConfigConverter))] +public record class PercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9962,7 +10206,7 @@ public JsonElement Json } } - public EventOutputConversionRateConfig( + public PercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9971,7 +10215,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig( + public PercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9980,7 +10224,7 @@ public EventOutputConversionRateConfig( this._element = element; } - public EventOutputConversionRateConfig(JsonElement element) + public PercentConversionRateConfig(JsonElement element) { this._element = element; } @@ -9989,7 +10233,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 +10254,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10274,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10285,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10062,7 +10306,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of EventOutputConversionRateConfig" + "Data did not match any variant of PercentConversionRateConfig" ); } } @@ -10071,7 +10315,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10326,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10098,16 +10342,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 PercentConversionRateConfig" ), }; } - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( + public static implicit operator PercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -10126,18 +10370,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 PercentConversionRateConfig" ); } 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(PercentConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10145,13 +10387,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 EventOutputConversionRateConfigConverter - : JsonConverter +sealed class PercentConversionRateConfigConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.EventOutputConversionRateConfig? Read( + public override PercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10180,12 +10434,10 @@ JsonSerializerOptions 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 +10454,10 @@ JsonSerializerOptions 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 +10466,14 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.EventOutputConversionRateConfig( - element - ); + return new PercentConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.EventOutputConversionRateConfig value, + PercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -10233,448 +10481,595 @@ 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 EventOutput : 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 - ) + /// + /// Configuration for event_output pricing + /// + public required EventOutputConfig EventOutputConfig { - 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("event_output_config"); + } + init { this._rawData.Set("event_output_config", value); } } -} -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class RemoveAdjustment : JsonModel -{ /// - /// The id of the adjustment to remove on the subscription. + /// The id of the item the price will be associated with. /// - public required string AdjustmentID + public required string ItemID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment_id"); + return this._rawData.GetNotNullClass("item_id"); } - init { this._rawData.Set("adjustment_id", value); } + init { this._rawData.Set("item_id", value); } } - /// - public override void Validate() + /// + /// The pricing model type + /// + public JsonElement ModelType { - _ = this.AdjustmentID; - } - - public RemoveAdjustment() { } - - public RemoveAdjustment(RemoveAdjustment removeAdjustment) - : base(removeAdjustment) { } - - public RemoveAdjustment(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemoveAdjustment(FrozenDictionary rawData) - { - this._rawData = new(rawData); - } -#pragma warning restore CS8618 - - /// - public static RemoveAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) - { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); - } - - [SetsRequiredMembers] - public RemoveAdjustment(string adjustmentID) - : this() - { - this.AdjustmentID = adjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct("model_type"); + } + init { this._rawData.Set("model_type", 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 name of the price. /// - public string? ExternalPriceID + public required string Name { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); + return this._rawData.GetNotNullClass("name"); } - init { this._rawData.Set("external_price_id", value); } + init { this._rawData.Set("name", value); } } /// - /// The id of the price to remove on the subscription. + /// The id of the billable metric for the price. Only needed if the price is usage-based. /// - public string? PriceID + public string? BillableMetricID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNullableClass("billable_metric_id"); } - init { this._rawData.Set("price_id", value); } - } - - /// - public override void Validate() - { - _ = this.ExternalPriceID; - _ = this.PriceID; - } - - public RemovePrice() { } - - public RemovePrice(RemovePrice removePrice) - : base(removePrice) { } - - public RemovePrice(IReadOnlyDictionary rawData) - { - this._rawData = new(rawData); - } - -#pragma warning disable CS8618 - [SetsRequiredMembers] - RemovePrice(FrozenDictionary rawData) - { - this._rawData = new(rawData); + init { this._rawData.Set("billable_metric_id", value); } } -#pragma warning restore CS8618 - /// - public static RemovePrice 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); } } -} - -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. + /// For custom cadence: specifies the duration of the billing period in days + /// or months. /// - public required ReplaceAdjustmentAdjustment Adjustment + public NewBillingCycleConfiguration? BillingCycleConfiguration { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("adjustment"); + return this._rawData.GetNullableClass( + "billing_cycle_configuration" + ); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("billing_cycle_configuration", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// The per unit conversion rate of the price currency to the invoicing currency. /// - public required string ReplacesAdjustmentID + public double? ConversionRate { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableStruct("conversion_rate"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("conversion_rate", value); } } - /// - public override void Validate() + /// + /// The configuration for the rate of the price currency to the invoicing currency. + /// + public EventOutputConversionRateConfig? ConversionRateConfig { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "conversion_rate_config" + ); + } + init { this._rawData.Set("conversion_rate_config", value); } } - public ReplaceAdjustment() { } - - public ReplaceAdjustment(ReplaceAdjustment replaceAdjustment) - : base(replaceAdjustment) { } - - public ReplaceAdjustment(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] - ReplaceAdjustment(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 ReplaceAdjustment 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); } } -} - -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 + /// + /// 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.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 ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) + public EventOutput() { - this.Value = value; - this._element = element; + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public ReplaceAdjustmentAdjustment(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public EventOutput(EventOutput eventOutput) + : base(eventOutput) { } +#pragma warning restore CS8618 + + public EventOutput(IReadOnlyDictionary rawData) { - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - /// - /// Returns true and sets the 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] + EventOutput(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 EventOutput FromRawUnchecked(IReadOnlyDictionary rawData) { - value = this.Value as NewUsageDiscount; - return value != null; + 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 +{ /// - /// Returns true and sets the 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 key in the event data to extract the unit rate from. /// - public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public required string UnitRatingKey { - value = this.Value as NewAmountDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + init { this._rawData.Set("unit_rating_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.TryPickNewMinimum(out var value)) { - /// // `value` is of type `NewMinimum` - /// Console.WriteLine(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 bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) + public string? DefaultUnitRate { - value = this.Value as NewMinimum; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_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.TryPickNewMaximum(out var value)) { - /// // `value` is of type `NewMaximum` - /// Console.WriteLine(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 bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) + public string? GroupingKey { - value = this.Value as NewMaximum; - return value != null; + 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 + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -10685,43 +11080,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 EventOutputConversionRateConfig" ); } } @@ -10730,7 +11110,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11121,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 EventOutputConversionRateConfig" ), }; } - 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 EventOutputConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); - public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum 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 @@ -10799,22 +11165,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 EventOutputConversionRateConfig" ); } - 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(EventOutputConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -10822,144 +11182,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 EventOutputConversionRateConfigConverter + : JsonConverter { - public override ReplaceAdjustmentAdjustment? Read( + public override EventOutputConversionRateConfig? 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); + return new EventOutputConversionRateConfig(element); } - case "minimum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - case "maximum": - { - try - { - var deserialized = JsonSerializer.Deserialize(element, options); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } - - return new(element); - } - default: - { - return new ReplaceAdjustmentAdjustment(element); - } - } - } + } + } public override void Write( Utf8JsonWriter writer, - ReplaceAdjustmentAdjustment value, + EventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -10967,127 +11277,138 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class ReplacePrice : JsonModel +[System::Obsolete("deprecated")] +[JsonConverter(typeof(ExternalMarketplaceConverter))] +public enum ExternalMarketplace { - /// - /// The id of the price on the plan to replace in the subscription. - /// - public required string ReplacesPriceID + Google, + Aws, + Azure, +} + +sealed class ExternalMarketplaceConverter : JsonConverter +{ + public override ExternalMarketplace Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) { - get + return JsonSerializer.Deserialize(ref reader, options) switch { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); - } - init { this._rawData.Set("replaces_price_id", value); } + "google" => ExternalMarketplace.Google, + "aws" => ExternalMarketplace.Aws, + "azure" => ExternalMarketplace.Azure, + _ => (ExternalMarketplace)(-1), + }; } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + public override void Write( + Utf8JsonWriter writer, + ExternalMarketplace value, + JsonSerializerOptions options + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + JsonSerializer.Serialize( + writer, + value switch + { + ExternalMarketplace.Google => "google", + ExternalMarketplace.Aws => "aws", + ExternalMarketplace.Azure => "azure", + _ => throw new OrbInvalidDataException( + string.Format("Invalid value '{0}' in {1}", value, nameof(value)) + ), + }, + options + ); } +} +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class RemoveAdjustment : JsonModel +{ /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. + /// The id of the adjustment to remove on the subscription. /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); + return this._rawData.GetNotNullClass("adjustment_id"); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The external price id of the price to add to the subscription. - /// - public string? ExternalPriceID + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("external_price_id"); - } - init { this._rawData.Set("external_price_id", value); } + _ = this.AdjustmentID; } - /// - /// The new quantity of the price, if the price is a fixed price. - /// - public double? FixedPriceQuantity + public RemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemoveAdjustment(RemoveAdjustment removeAdjustment) + : base(removeAdjustment) { } +#pragma warning restore CS8618 + + public RemoveAdjustment(IReadOnlyDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); - } - init { this._rawData.Set("fixed_price_quantity", value); } + this._rawData = new(rawData); } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MaximumAmount +#pragma warning disable CS8618 + [SetsRequiredMembers] + RemoveAdjustment(FrozenDictionary rawData) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } + this._rawData = new(rawData); } +#pragma warning restore CS8618 - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + /// + public static RemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } + 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 +{ /// - /// New subscription price request body params. + /// The external price id of the price to remove on the subscription. /// - public ReplacePricePrice? Price + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price"); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The id of the price to add to the subscription. + /// The id of the price to remove on the subscription. /// public string? PriceID { @@ -11102,2903 +11423,4777 @@ public string? PriceID /// public override void Validate() { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) - { - item.Validate(); - } _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); _ = this.PriceID; } - public ReplacePrice() { } + public RemovePrice() { } - public ReplacePrice(ReplacePrice replacePrice) - : base(replacePrice) { } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public RemovePrice(RemovePrice removePrice) + : base(removePrice) { } +#pragma warning restore CS8618 - public ReplacePrice(IReadOnlyDictionary rawData) + public RemovePrice(IReadOnlyDictionary rawData) { this._rawData = new(rawData); } #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePrice(FrozenDictionary rawData) + RemovePrice(FrozenDictionary rawData) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) + /// + public static RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public ReplacePrice(string replacesPriceID) - : this() - { - this.ReplacesPriceID = replacesPriceID; - } } -class ReplacePriceFromRaw : IFromRawJson +class RemovePriceFromRaw : IFromRawJson { /// - public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => - ReplacePrice.FromRawUnchecked(rawData); + public RemovePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + RemovePrice.FromRawUnchecked(rawData); } -/// -/// New subscription price request body params. -/// -[JsonConverter(typeof(ReplacePricePriceConverter))] -public record class ReplacePricePrice : ModelBase +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplaceAdjustment : JsonModel { - public object? Value { get; } = null; - - JsonElement? _element = null; - - public JsonElement Json - { - get - { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + /// + /// 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); } } - public string ItemID + /// + /// The id of the adjustment on the plan to replace in the subscription. + /// + public required string ReplacesAdjustmentID { 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.GetNotNullClass("replaces_adjustment_id"); } + init { this._rawData.Set("replaces_adjustment_id", value); } } - public string Name + /// + 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 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 + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions ); } } - public string? BillableMetricID + public string? Currency { 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 + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency ); } } - public bool? BilledInAdvance + public bool? IsInvoiceLevel { 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 + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel ); } } - public NewBillingCycleConfiguration? BillingCycleConfiguration + public ReplaceAdjustmentAdjustment(NewPercentageDiscount value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillingCycleConfiguration, - newSubscriptionTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newSubscriptionPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + this.Value = value; + this._element = element; } - public double? ConversionRate + public ReplaceAdjustmentAdjustment(NewUsageDiscount value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ConversionRate, - newSubscriptionTiered: (x) => x.ConversionRate, - newSubscriptionBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newSubscriptionPackage: (x) => x.ConversionRate, - newSubscriptionMatrix: (x) => x.ConversionRate, - newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, - newSubscriptionTieredPackage: (x) => x.ConversionRate, - newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedTiered: (x) => x.ConversionRate, - newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, - newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, - newSubscriptionUnitWithPercent: (x) => x.ConversionRate, - newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newSubscriptionUnitWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedAllocation: (x) => x.ConversionRate, - newSubscriptionBulkWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, - newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, - newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newSubscriptionMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + this.Value = value; + this._element = element; } - public string? Currency + public ReplaceAdjustmentAdjustment(NewAmountDiscount value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Currency, - newSubscriptionTiered: (x) => x.Currency, - newSubscriptionBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newSubscriptionPackage: (x) => x.Currency, - newSubscriptionMatrix: (x) => x.Currency, - newSubscriptionThresholdTotalAmount: (x) => x.Currency, - newSubscriptionTieredPackage: (x) => x.Currency, - newSubscriptionTieredWithMinimum: (x) => x.Currency, - newSubscriptionGroupedTiered: (x) => x.Currency, - newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, - newSubscriptionPackageWithAllocation: (x) => x.Currency, - newSubscriptionUnitWithPercent: (x) => x.Currency, - newSubscriptionMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newSubscriptionUnitWithProration: (x) => x.Currency, - newSubscriptionGroupedAllocation: (x) => x.Currency, - newSubscriptionBulkWithProration: (x) => x.Currency, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newSubscriptionMatrixWithDisplayName: (x) => x.Currency, - newSubscriptionGroupedTieredPackage: (x) => x.Currency, - newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, - newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newSubscriptionMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + this.Value = value; + this._element = element; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public ReplaceAdjustmentAdjustment(NewMinimum value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + this.Value = value; + this._element = element; } - public string? ExternalPriceID + public ReplaceAdjustmentAdjustment(NewMaximum value, JsonElement? element = null) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ExternalPriceID, - newSubscriptionTiered: (x) => x.ExternalPriceID, - newSubscriptionBulk: (x) => x.ExternalPriceID, - bulkWithFilters: (x) => x.ExternalPriceID, - newSubscriptionPackage: (x) => x.ExternalPriceID, - newSubscriptionMatrix: (x) => x.ExternalPriceID, - newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, - newSubscriptionTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, - newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, - newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, - tieredWithProration: (x) => x.ExternalPriceID, - newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, - newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, - groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, - newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, - cumulativeGroupedAllocation: (x) => x.ExternalPriceID, - minimum: (x) => x.ExternalPriceID, - newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, - percent: (x) => x.ExternalPriceID, - eventOutput: (x) => x.ExternalPriceID - ); - } + this.Value = value; + this._element = element; } - public double? FixedPriceQuantity + public ReplaceAdjustmentAdjustment(JsonElement element) { - 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._element = element; } - public string? InvoiceGroupingKey + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoiceGroupingKey, - newSubscriptionTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newSubscriptionPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, - newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } + value = this.Value as NewPercentageDiscount; + return value != null; } - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } + value = this.Value as NewUsageDiscount; + return value != null; } - public string? ReferenceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } + value = this.Value as NewAmountDiscount; + return value != null; } - public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - this.Value = value; - this._element = element; + value = this.Value as NewMinimum; + return value != null; } - public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - this.Value = value; - this._element = element; + value = this.Value as NewMaximum; + return value != null; } - public ReplacePricePrice(NewSubscriptionBulkPrice 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( + /// (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 + ) { - this.Value = value; - this._element = element; + 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" + ); + } } - public ReplacePricePrice(ReplacePricePriceBulkWithFilters 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( + /// (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 + ) { - this.Value = value; - this._element = element; + 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 ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewPercentageDiscount value) => + new(value); - public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewUsageDiscount value) => + new(value); - public ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewAmountDiscount value) => + new(value); - public ReplacePricePrice(NewSubscriptionTieredPackagePrice value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewMinimum value) => new(value); - public ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator ReplaceAdjustmentAdjustment(NewMaximum 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 ReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public virtual bool Equals(ReplaceAdjustmentAdjustment? 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 + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; } +} - public ReplacePricePrice( - ReplacePricePriceTieredWithProration value, - JsonElement? element = null +sealed class ReplaceAdjustmentAdjustmentConverter : JsonConverter +{ + public override ReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; - } + var element = JsonSerializer.Deserialize(ref reader, options); + string? adjustmentType; + try + { + adjustmentType = element.GetProperty("adjustment_type").GetString(); + } + catch + { + adjustmentType = null; + } - public ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + switch (adjustmentType) + { + case "percentage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "usage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + 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 ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + ReplaceAdjustmentAdjustment value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize(writer, value.Json, options); } +} - public ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) +[JsonConverter(typeof(JsonModelConverter))] +public sealed record class ReplacePrice : JsonModel +{ + /// + /// The id of the price on the plan to replace in the subscription. + /// + public required string ReplacesPriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } } - public ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) + /// + /// The definition of a new allocation price to create and add to the subscription. + /// + public NewAllocationPrice? AllocationPrice { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } - public ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. + /// + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } - public ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) + /// + /// The external price id of the price to add to 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( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) + /// + /// The new quantity of the price, if the price is a fixed price. + /// + 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( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } - public ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides { - this.Value = value; - this._element = element; + 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 ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MinimumAmount { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("minimum_amount"); + } + init { this._rawData.Set("minimum_amount", value); } } - public ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + /// + /// New subscription price request body params. + /// + public ReplacePricePrice? Price { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("price"); + } + init { this._rawData.Set("price", value); } } - public ReplacePricePrice(ReplacePricePriceMinimum value, JsonElement? element = null) + /// + /// The id of the price to add to 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( - NewSubscriptionMinimumCompositePrice value, - JsonElement? element = null - ) + /// + public override void Validate() { - this.Value = value; - this._element = element; + _ = this.ReplacesPriceID; + this.AllocationPrice?.Validate(); + foreach (var item in this.Discounts ?? []) + { + item.Validate(); + } + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; + _ = this.MinimumAmount; + this.Price?.Validate(); + _ = this.PriceID; } - public ReplacePricePrice(ReplacePricePricePercent value, JsonElement? element = null) - { - this.Value = value; - this._element = element; - } + public ReplacePrice() { } - public ReplacePricePrice(ReplacePricePriceEventOutput value, JsonElement? element = null) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public ReplacePrice(ReplacePrice replacePrice) + : base(replacePrice) { } +#pragma warning restore CS8618 + + public ReplacePrice(IReadOnlyDictionary rawData) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); } - public ReplacePricePrice(JsonElement element) +#pragma warning disable CS8618 + [SetsRequiredMembers] + ReplacePrice(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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + /// + public static ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) { - value = this.Value as NewSubscriptionUnitPrice; - 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value - ) + [SetsRequiredMembers] + public ReplacePrice(string replacesPriceID) + : this() { - value = this.Value as NewSubscriptionTieredPrice; - 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.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; - } +class ReplacePriceFromRaw : IFromRawJson +{ + /// + public ReplacePrice FromRawUnchecked(IReadOnlyDictionary rawData) => + ReplacePrice.FromRawUnchecked(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 - ) - { - value = this.Value as ReplacePricePriceBulkWithFilters; - return value != null; - } +/// +/// New subscription price request body params. +/// +[JsonConverter(typeof(ReplacePricePriceConverter))] +public record class ReplacePricePrice : ModelBase +{ + public object? Value { get; } = null; - /// - /// Returns true and sets the 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; - } + JsonElement? _element = null; - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrix(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrix( - [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value - ) + public JsonElement Json { - value = this.Value as NewSubscriptionMatrixPrice; - 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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value - ) + public string ItemID { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value - ) + public string Name { - value = this.Value as NewSubscriptionTieredPackagePrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value - ) + public bool? BilledInAdvance { - value = this.Value as NewSubscriptionGroupedTieredPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.BilledInAdvance, + newSubscriptionTiered: (x) => x.BilledInAdvance, + newSubscriptionBulk: (x) => x.BilledInAdvance, + bulkWithFilters: (x) => x.BilledInAdvance, + newSubscriptionPackage: (x) => x.BilledInAdvance, + newSubscriptionMatrix: (x) => x.BilledInAdvance, + newSubscriptionThresholdTotalAmount: (x) => x.BilledInAdvance, + newSubscriptionTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionTieredWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedTiered: (x) => x.BilledInAdvance, + newSubscriptionTieredPackageWithMinimum: (x) => x.BilledInAdvance, + newSubscriptionPackageWithAllocation: (x) => x.BilledInAdvance, + newSubscriptionUnitWithPercent: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithAllocation: (x) => x.BilledInAdvance, + tieredWithProration: (x) => x.BilledInAdvance, + newSubscriptionUnitWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedAllocation: (x) => x.BilledInAdvance, + newSubscriptionBulkWithProration: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BilledInAdvance, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BilledInAdvance, + groupedWithMinMaxThresholds: (x) => x.BilledInAdvance, + newSubscriptionMatrixWithDisplayName: (x) => x.BilledInAdvance, + newSubscriptionGroupedTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionMaxGroupTieredPackage: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BilledInAdvance, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BilledInAdvance, + newSubscriptionCumulativeGroupedBulk: (x) => x.BilledInAdvance, + cumulativeGroupedAllocation: (x) => x.BilledInAdvance, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) + public double? ConversionRate { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) + public string? Currency { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.Currency, + newSubscriptionTiered: (x) => x.Currency, + newSubscriptionBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newSubscriptionPackage: (x) => x.Currency, + newSubscriptionMatrix: (x) => x.Currency, + newSubscriptionThresholdTotalAmount: (x) => x.Currency, + newSubscriptionTieredPackage: (x) => x.Currency, + newSubscriptionTieredWithMinimum: (x) => x.Currency, + newSubscriptionGroupedTiered: (x) => x.Currency, + newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, + newSubscriptionPackageWithAllocation: (x) => x.Currency, + newSubscriptionUnitWithPercent: (x) => x.Currency, + newSubscriptionMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newSubscriptionUnitWithProration: (x) => x.Currency, + newSubscriptionGroupedAllocation: (x) => x.Currency, + newSubscriptionBulkWithProration: (x) => x.Currency, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newSubscriptionMatrixWithDisplayName: (x) => x.Currency, + newSubscriptionGroupedTieredPackage: (x) => x.Currency, + newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, + newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - 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 `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; + 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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ExternalPriceID, + newSubscriptionTiered: (x) => x.ExternalPriceID, + newSubscriptionBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newSubscriptionPackage: (x) => x.ExternalPriceID, + newSubscriptionMatrix: (x) => x.ExternalPriceID, + newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, + newSubscriptionTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, + newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, + newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - value = this.Value as NewSubscriptionGroupedWithMeteredMinimumPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, + bulkWithFilters: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, + tieredWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => + x.InvoicingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, + dailyCreditAllowance: (x) => x.InvoicingCycleConfiguration, + meteredAllowance: (x) => x.InvoicingCycleConfiguration, + newSubscriptionMinimumComposite: (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.TryPickGroupedWithMinMaxThresholds(out var value)) { - /// // `value` is of type `ReplacePricePriceGroupedWithMinMaxThresholds` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickGroupedWithMinMaxThresholds( - [NotNullWhen(true)] out ReplacePricePriceGroupedWithMinMaxThresholds? value - ) + public string? LicenseTypeID { - value = this.Value as ReplacePricePriceGroupedWithMinMaxThresholds; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value - ) + public string? ReferenceID { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; + 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, + dailyCreditAllowance: (x) => x.ReferenceID, + meteredAllowance: (x) => x.ReferenceID, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) + public ReplacePricePrice(NewSubscriptionUnitPrice value, JsonElement? element = null) { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - 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.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) + public ReplacePricePrice(NewSubscriptionTieredPrice value, JsonElement? element = null) { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - 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.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) + public ReplacePricePrice(NewSubscriptionBulkPrice value, JsonElement? element = null) { - value = this.Value as NewSubscriptionScalableMatrixWithUnitPricingPrice; - 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.TryPickNewSubscriptionScalableMatrixWithTieredPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithTieredPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithTieredPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithTieredPricingPrice? value - ) + public ReplacePricePrice(ReplacePricePriceBulkWithFilters value, JsonElement? element = null) { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - 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.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value - ) + public ReplacePricePrice(NewSubscriptionPackagePrice value, JsonElement? element = null) { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - 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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `ReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] out ReplacePricePriceCumulativeGroupedAllocation? value - ) + public ReplacePricePrice(NewSubscriptionMatrixPrice value, JsonElement? element = null) { - value = this.Value as ReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `ReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum([NotNullWhen(true)] out ReplacePricePriceMinimum? value) + public ReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null + ) { - value = this.Value as ReplacePricePriceMinimum; - return value != 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( + 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 . + /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// - /// if (instance.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` + /// if (instance.TryPickNewSubscriptionUnit(out var value)) { + /// // `value` is of type `NewSubscriptionUnitPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value - ) + public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) { - value = this.Value as NewSubscriptionMinimumCompositePrice; + 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 . + /// 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 `ReplacePricePricePercent` + /// if (instance.TryPickNewSubscriptionTiered(out var value)) { + /// // `value` is of type `NewSubscriptionTieredPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickPercent([NotNullWhen(true)] out ReplacePricePricePercent? value) + public bool TryPickNewSubscriptionTiered( + [NotNullWhen(true)] out NewSubscriptionTieredPrice? value + ) { - value = this.Value as ReplacePricePricePercent; + 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 . + /// 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 `ReplacePricePriceEventOutput` + /// if (instance.TryPickNewSubscriptionBulk(out var value)) { + /// // `value` is of type `NewSubscriptionBulkPrice` /// Console.WriteLine(value); /// } /// /// /// - public bool TryPickEventOutput([NotNullWhen(true)] out ReplacePricePriceEventOutput? value) + public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) { - value = this.Value as ReplacePricePriceEventOutput; + value = this.Value as NewSubscriptionBulkPrice; return value != null; } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// 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( - /// (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) => {...} - /// ); + /// if (instance.TryPickBulkWithFilters(out var value)) { + /// // `value` is of type `ReplacePricePriceBulkWithFilters` + /// Console.WriteLine(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 bool TryPickBulkWithFilters( + [NotNullWhen(true)] out ReplacePricePriceBulkWithFilters? value ) { - switch (this.Value) - { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case ReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case ReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case ReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case ReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case ReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case ReplacePricePricePercent value: - percent(value); - break; - case ReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } + value = this.Value as ReplacePricePriceBulkWithFilters; + return value != 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. + /// 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. /// /// /// - /// 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) => {...} - /// ); + /// if (instance.TryPickNewSubscriptionPackage(out var value)) { + /// // `value` is of type `NewSubscriptionPackagePrice` + /// Console.WriteLine(value); + /// } /// /// /// - public T Match( - System::Func newSubscriptionUnit, - System::Func newSubscriptionTiered, - System::Func newSubscriptionBulk, - System::Func bulkWithFilters, - System::Func newSubscriptionPackage, - System::Func newSubscriptionMatrix, - System::Func< - NewSubscriptionThresholdTotalAmountPrice, - T - > newSubscriptionThresholdTotalAmount, - System::Func newSubscriptionTieredPackage, - System::Func newSubscriptionTieredWithMinimum, - System::Func newSubscriptionGroupedTiered, - System::Func< - NewSubscriptionTieredPackageWithMinimumPrice, - T - > newSubscriptionTieredPackageWithMinimum, - System::Func< - NewSubscriptionPackageWithAllocationPrice, - T - > newSubscriptionPackageWithAllocation, - System::Func newSubscriptionUnitWithPercent, - System::Func< - NewSubscriptionMatrixWithAllocationPrice, - T - > newSubscriptionMatrixWithAllocation, - System::Func tieredWithProration, - System::Func newSubscriptionUnitWithProration, - System::Func newSubscriptionGroupedAllocation, - System::Func newSubscriptionBulkWithProration, - System::Func< - NewSubscriptionGroupedWithProratedMinimumPrice, - T - > newSubscriptionGroupedWithProratedMinimum, - System::Func< - NewSubscriptionGroupedWithMeteredMinimumPrice, - T - > newSubscriptionGroupedWithMeteredMinimum, - System::Func groupedWithMinMaxThresholds, - System::Func< - NewSubscriptionMatrixWithDisplayNamePrice, - T - > newSubscriptionMatrixWithDisplayName, - System::Func< - NewSubscriptionGroupedTieredPackagePrice, - T - > newSubscriptionGroupedTieredPackage, - System::Func< - NewSubscriptionMaxGroupTieredPackagePrice, - T - > newSubscriptionMaxGroupTieredPackage, - System::Func< - NewSubscriptionScalableMatrixWithUnitPricingPrice, - T - > newSubscriptionScalableMatrixWithUnitPricing, - System::Func< - NewSubscriptionScalableMatrixWithTieredPricingPrice, - T - > newSubscriptionScalableMatrixWithTieredPricing, - System::Func< - NewSubscriptionCumulativeGroupedBulkPrice, - T - > newSubscriptionCumulativeGroupedBulk, - System::Func cumulativeGroupedAllocation, - System::Func minimum, - System::Func newSubscriptionMinimumComposite, - System::Func percent, - System::Func eventOutput + public bool TryPickNewSubscriptionPackage( + [NotNullWhen(true)] out NewSubscriptionPackagePrice? value ) { - return this.Value switch - { - NewSubscriptionUnitPrice value => newSubscriptionUnit(value), - NewSubscriptionTieredPrice value => newSubscriptionTiered(value), - NewSubscriptionBulkPrice value => newSubscriptionBulk(value), - ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), - NewSubscriptionPackagePrice value => newSubscriptionPackage(value), - NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), - NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( - value - ), - NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), - NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), - NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), - NewSubscriptionTieredPackageWithMinimumPrice value => - newSubscriptionTieredPackageWithMinimum(value), - NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( - value - ), - NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), - NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( - value - ), - ReplacePricePriceTieredWithProration value => tieredWithProration(value), - NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), - NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), - NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), - NewSubscriptionGroupedWithProratedMinimumPrice value => - newSubscriptionGroupedWithProratedMinimum(value), - NewSubscriptionGroupedWithMeteredMinimumPrice value => - newSubscriptionGroupedWithMeteredMinimum(value), - ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( - value - ), - NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( - value - ), - NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( - value - ), - NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( - value - ), - NewSubscriptionScalableMatrixWithUnitPricingPrice value => - newSubscriptionScalableMatrixWithUnitPricing(value), - NewSubscriptionScalableMatrixWithTieredPricingPrice value => - newSubscriptionScalableMatrixWithTieredPricing(value), - NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( - value - ), - ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( - value - ), - ReplacePricePriceMinimum value => minimum(value), - NewSubscriptionMinimumCompositePrice value => newSubscriptionMinimumComposite(value), - ReplacePricePricePercent value => percent(value), - ReplacePricePriceEventOutput value => eventOutput(value), - _ => throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ), - }; + value = this.Value as NewSubscriptionPackagePrice; + return value != null; } - public static implicit operator ReplacePricePrice(NewSubscriptionUnitPrice value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionBulkPrice value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceBulkWithFilters value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMatrixPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionTieredPackagePrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionGroupedTieredPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionUnitWithPercentPrice value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceTieredWithProration value) => - new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); - - public static implicit operator ReplacePricePrice( - ReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceMinimum value) => new(value); - - public static implicit operator ReplacePricePrice(NewSubscriptionMinimumCompositePrice value) => - new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePricePercent value) => new(value); - - public static implicit operator ReplacePricePrice(ReplacePricePriceEventOutput value) => - new(value); - /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). + /// 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.TryPickNewSubscriptionMatrix(out var value)) { + /// // `value` is of type `NewSubscriptionMatrixPrice` + /// Console.WriteLine(value); + /// } + /// + /// /// - public override void Validate() - { - if (this.Value == null) - { - throw new OrbInvalidDataException( - "Data did not match any variant of ReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); - } - - public virtual bool Equals(ReplacePricePrice? other) + public bool TryPickNewSubscriptionMatrix( + [NotNullWhen(true)] out NewSubscriptionMatrixPrice? value + ) { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + value = this.Value as NewSubscriptionMatrixPrice; + 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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { + /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionThresholdTotalAmount( + [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + ) { - return 0; + value = this.Value as NewSubscriptionThresholdTotalAmountPrice; + 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.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; + } -sealed class ReplacePricePriceConverter : JsonConverter -{ - public override ReplacePricePrice? 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { + /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewSubscriptionTieredWithMinimum( + [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value ) { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch - { - modelType = null; - } + value = this.Value as NewSubscriptionTieredWithMinimumPrice; + 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.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; + } - return new(element); - } - case "tiered": - { - try - { - var deserialized = JsonSerializer.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.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; + } - 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.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; + } - 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.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; + } - 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.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; + } - return new(element); - } - case "matrix": + /// + /// Returns true and sets the 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) => {...}, + /// (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 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 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) => {...}, + /// (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, + System::Func newSubscriptionPackage, + System::Func newSubscriptionMatrix, + System::Func< + NewSubscriptionThresholdTotalAmountPrice, + T + > newSubscriptionThresholdTotalAmount, + System::Func newSubscriptionTieredPackage, + System::Func newSubscriptionTieredWithMinimum, + System::Func newSubscriptionGroupedTiered, + System::Func< + NewSubscriptionTieredPackageWithMinimumPrice, + T + > newSubscriptionTieredPackageWithMinimum, + System::Func< + NewSubscriptionPackageWithAllocationPrice, + T + > newSubscriptionPackageWithAllocation, + System::Func newSubscriptionUnitWithPercent, + System::Func< + NewSubscriptionMatrixWithAllocationPrice, + T + > newSubscriptionMatrixWithAllocation, + System::Func tieredWithProration, + System::Func newSubscriptionUnitWithProration, + System::Func newSubscriptionGroupedAllocation, + System::Func newSubscriptionBulkWithProration, + System::Func< + NewSubscriptionGroupedWithProratedMinimumPrice, + T + > newSubscriptionGroupedWithProratedMinimum, + System::Func< + NewSubscriptionGroupedWithMeteredMinimumPrice, + T + > newSubscriptionGroupedWithMeteredMinimum, + System::Func groupedWithMinMaxThresholds, + System::Func< + NewSubscriptionMatrixWithDisplayNamePrice, + T + > newSubscriptionMatrixWithDisplayName, + System::Func< + NewSubscriptionGroupedTieredPackagePrice, + T + > newSubscriptionGroupedTieredPackage, + System::Func< + NewSubscriptionMaxGroupTieredPackagePrice, + T + > newSubscriptionMaxGroupTieredPackage, + System::Func< + NewSubscriptionScalableMatrixWithUnitPricingPrice, + T + > newSubscriptionScalableMatrixWithUnitPricing, + System::Func< + NewSubscriptionScalableMatrixWithTieredPricingPrice, + T + > newSubscriptionScalableMatrixWithTieredPricing, + System::Func< + NewSubscriptionCumulativeGroupedBulkPrice, + T + > newSubscriptionCumulativeGroupedBulk, + System::Func cumulativeGroupedAllocation, + System::Func dailyCreditAllowance, + System::Func meteredAllowance, + System::Func newSubscriptionMinimumComposite, + System::Func percent, + System::Func eventOutput + ) + { + return this.Value switch + { + NewSubscriptionUnitPrice value => newSubscriptionUnit(value), + NewSubscriptionTieredPrice value => newSubscriptionTiered(value), + NewSubscriptionBulkPrice value => newSubscriptionBulk(value), + ReplacePricePriceBulkWithFilters value => bulkWithFilters(value), + NewSubscriptionPackagePrice value => newSubscriptionPackage(value), + NewSubscriptionMatrixPrice value => newSubscriptionMatrix(value), + NewSubscriptionThresholdTotalAmountPrice value => newSubscriptionThresholdTotalAmount( + value + ), + NewSubscriptionTieredPackagePrice value => newSubscriptionTieredPackage(value), + NewSubscriptionTieredWithMinimumPrice value => newSubscriptionTieredWithMinimum(value), + NewSubscriptionGroupedTieredPrice value => newSubscriptionGroupedTiered(value), + NewSubscriptionTieredPackageWithMinimumPrice value => + newSubscriptionTieredPackageWithMinimum(value), + NewSubscriptionPackageWithAllocationPrice value => newSubscriptionPackageWithAllocation( + value + ), + NewSubscriptionUnitWithPercentPrice value => newSubscriptionUnitWithPercent(value), + NewSubscriptionMatrixWithAllocationPrice value => newSubscriptionMatrixWithAllocation( + value + ), + ReplacePricePriceTieredWithProration value => tieredWithProration(value), + NewSubscriptionUnitWithProrationPrice value => newSubscriptionUnitWithProration(value), + NewSubscriptionGroupedAllocationPrice value => newSubscriptionGroupedAllocation(value), + NewSubscriptionBulkWithProrationPrice value => newSubscriptionBulkWithProration(value), + NewSubscriptionGroupedWithProratedMinimumPrice value => + newSubscriptionGroupedWithProratedMinimum(value), + NewSubscriptionGroupedWithMeteredMinimumPrice value => + newSubscriptionGroupedWithMeteredMinimum(value), + ReplacePricePriceGroupedWithMinMaxThresholds value => groupedWithMinMaxThresholds( + value + ), + NewSubscriptionMatrixWithDisplayNamePrice value => newSubscriptionMatrixWithDisplayName( + value + ), + NewSubscriptionGroupedTieredPackagePrice value => newSubscriptionGroupedTieredPackage( + value + ), + NewSubscriptionMaxGroupTieredPackagePrice value => newSubscriptionMaxGroupTieredPackage( + value + ), + NewSubscriptionScalableMatrixWithUnitPricingPrice value => + newSubscriptionScalableMatrixWithUnitPricing(value), + NewSubscriptionScalableMatrixWithTieredPricingPrice value => + newSubscriptionScalableMatrixWithTieredPricing(value), + NewSubscriptionCumulativeGroupedBulkPrice value => newSubscriptionCumulativeGroupedBulk( + value + ), + ReplacePricePriceCumulativeGroupedAllocation value => cumulativeGroupedAllocation( + value + ), + 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(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(), + (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, + ReplacePricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + ReplacePricePriceGroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + ReplacePricePriceCumulativeGroupedAllocation _ => 27, + ReplacePricePriceDailyCreditAllowance _ => 28, + ReplacePricePriceMeteredAllowance _ => 29, + NewSubscriptionMinimumCompositePrice _ => 30, + ReplacePricePricePercent _ => 31, + ReplacePricePriceEventOutput _ => 32, + _ => -1, + }; + } +} + +sealed class ReplacePricePriceConverter : JsonConverter +{ + public override ReplacePricePrice? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? modelType; + try + { + modelType = element.GetProperty("model_type").GetString(); + } + catch + { + modelType = null; + } + + switch (modelType) + { + case "unit": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "bulk_with_filters": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "threshold_total_amount": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "grouped_tiered": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_package_with_minimum": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "package_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_percent": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "matrix_with_allocation": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "tiered_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + return new(element); + } + case "unit_with_proration": + { + try + { + var deserialized = + JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } + + 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( + 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) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // 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); + } + 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 - 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 static ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } +class ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson +{ + /// + public ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter FromRawUnchecked( + IReadOnlyDictionary rawData + ) => ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter.FromRawUnchecked(rawData); +} - 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 - } +/// +/// 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); } + } - 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 - } + /// + /// 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 "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 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), + }; + } - return new(element); - } - case "unit_with_percent": + public override void Write( + Utf8JsonWriter writer, + ReplacePricePriceBulkWithFiltersCadence 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 - } + 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 + ); + } +} - 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 - } +[JsonConverter(typeof(ReplacePricePriceBulkWithFiltersConversionRateConfigConverter))] +public record class ReplacePricePriceBulkWithFiltersConversionRateConfig : ModelBase +{ + public object? Value { get; } = 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 - } + JsonElement? _element = 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 - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public ReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig 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 ReplacePricePriceBulkWithFiltersConversionRateConfig(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; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } - return new(element); - } - case "grouped_with_min_max_thresholds": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } - return new(element); - } - case "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 and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of ReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } - return new(element); - } - case "grouped_tiered_package": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public static implicit operator ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 ReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + 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(ReplacePricePriceBulkWithFiltersConversionRateConfig? 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": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } +sealed class ReplacePricePriceBulkWithFiltersConversionRateConfigConverter + : JsonConverter +{ + public override ReplacePricePriceBulkWithFiltersConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + conversionRateType = element.GetProperty("conversion_rate_type").GetString(); + } + catch + { + conversionRateType = null; + } - return new(element); - } - case "percent": + switch (conversionRateType) + { + case "unit": { try { - var deserialized = JsonSerializer.Deserialize( + var deserialized = JsonSerializer.Deserialize( element, options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } return new(element); } - case "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 +16202,39 @@ JsonSerializerOptions options } default: { - return new ReplacePricePrice(element); + return new ReplacePricePriceBulkWithFiltersConversionRateConfig(element); } } } public override void Write( Utf8JsonWriter writer, - ReplacePricePrice? value, + ReplacePricePriceBulkWithFiltersConversionRateConfig 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 +16279,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 +16353,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 +16449,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +16500,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 +16524,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 +16566,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 +16695,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + ReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -14536,76 +16703,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 +16794,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -14622,93 +16802,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 +16839,7 @@ public JsonElement Json } } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -14734,7 +16848,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig( + public ReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -14743,7 +16857,7 @@ public ReplacePricePriceBulkWithFiltersConversionRateConfig( this._element = element; } - public ReplacePricePriceBulkWithFiltersConversionRateConfig(JsonElement element) + public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) { this._element = element; } @@ -14752,7 +16866,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 +16887,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +16907,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +16918,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14825,7 +16939,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 +16948,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +16959,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -14861,16 +16975,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 +17003,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 +17020,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 +17068,10 @@ JsonSerializerOptions 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 +17088,10 @@ JsonSerializerOptions 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 +17100,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 +17117,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 +17192,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 +17251,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 +17347,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17399,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 +17422,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 +17466,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 +17489,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 +17500,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 +17520,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 +17536,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 +17627,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -15554,8 +17635,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15563,18 +17644,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 +17674,7 @@ public JsonElement Json } } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15600,7 +17683,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig( + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15609,7 +17692,7 @@ public ReplacePricePriceTieredWithProrationConversionRateConfig( this._element = element; } - public ReplacePricePriceTieredWithProrationConversionRateConfig(JsonElement element) + public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) { this._element = element; } @@ -15618,7 +17701,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 +17722,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +17742,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +17753,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15691,7 +17774,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 +17783,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +17794,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15727,16 +17810,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 +17838,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 +17857,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 +17905,10 @@ JsonSerializerOptions 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 +17925,10 @@ JsonSerializerOptions 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 +17937,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 +17956,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 +18090,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 +18186,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18238,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 +18261,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 +18305,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 +18328,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 +18339,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 +18359,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 +18375,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 +18466,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -16358,8 +18474,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16367,20 +18483,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 +18513,7 @@ public JsonElement Json } } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16406,7 +18522,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16415,7 +18531,7 @@ public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( this._element = element; } - public ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig(JsonElement element) + public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) { this._element = element; } @@ -16424,7 +18540,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 +18561,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18581,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18592,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16497,7 +18613,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 +18622,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18633,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16533,16 +18649,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 +18677,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 +18696,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 +18744,10 @@ JsonSerializerOptions 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 +18764,10 @@ JsonSerializerOptions 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 +18776,7 @@ JsonSerializerOptions options } default: { - return new ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -16660,7 +18785,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - ReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -16670,40 +18795,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 +18929,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 +19025,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19077,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 +19100,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 +19142,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 +19165,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 +19176,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 +19409,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 +19432,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -17168,8 +19440,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static ReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static ReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17177,20 +19449,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 +19479,7 @@ public JsonElement Json } } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17216,7 +19488,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17225,7 +19497,7 @@ public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( this._element = element; } - public ReplacePricePriceCumulativeGroupedAllocationConversionRateConfig(JsonElement element) + public ReplacePricePriceDailyCreditAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -17234,7 +19506,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 +19527,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +19547,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +19558,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17307,7 +19579,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 +19588,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +19599,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17343,16 +19615,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 +19643,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 +19660,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 +19708,10 @@ JsonSerializerOptions 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 +19728,10 @@ JsonSerializerOptions 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 +19740,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 +19756,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 +19792,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 +19891,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 +19987,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +20040,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 +20062,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 +20104,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 +20126,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 +20137,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 +20157,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 +20173,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 +20278,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 +20356,7 @@ public JsonElement Json } } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17992,7 +20365,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig( + public ReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18001,7 +20374,7 @@ public ReplacePricePriceMinimumConversionRateConfig( this._element = element; } - public ReplacePricePriceMinimumConversionRateConfig(JsonElement element) + public ReplacePricePriceMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -18010,7 +20383,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 +20404,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +20424,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +20435,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18083,7 +20456,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 +20465,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +20476,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18119,16 +20492,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 +20520,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 +20537,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 +20585,10 @@ JsonSerializerOptions 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 +20605,10 @@ JsonSerializerOptions 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 +20617,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 +20861,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +20931,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -18545,8 +20941,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 +21071,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 +21162,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 +21183,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21203,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21214,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18842,7 +21244,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21255,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18903,10 +21305,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 +21316,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +21364,10 @@ JsonSerializerOptions 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 +21384,10 @@ JsonSerializerOptions 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 +21640,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +21715,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19300,8 +21725,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 +21886,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 +21979,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 +22000,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +22020,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +22031,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19630,7 +22061,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +22072,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19691,10 +22122,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 +22133,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +22181,10 @@ JsonSerializerOptions 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 +22201,10 @@ JsonSerializerOptions 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..06132e1bd 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionPriceIntervalsParams.cs @@ -80,8 +80,12 @@ namespace Orb.Models.Subscriptions; /// list of transitions must be specified to add additional transitions. The existing /// list of transitions can be retrieved using the `fixed_fee_quantity_transitions` /// property on a subscription’s serialized price intervals. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionPriceIntervalsParams : ParamsBase +public record class SubscriptionPriceIntervalsParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -222,6 +226,8 @@ public IReadOnlyList? EditAdjustments public SubscriptionPriceIntervalsParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionPriceIntervalsParams( SubscriptionPriceIntervalsParams subscriptionPriceIntervalsParams ) @@ -231,6 +237,7 @@ SubscriptionPriceIntervalsParams subscriptionPriceIntervalsParams this._rawBodyData = new(subscriptionPriceIntervalsParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionPriceIntervalsParams( IReadOnlyDictionary rawHeaderData, @@ -248,27 +255,61 @@ IReadOnlyDictionary rawBodyData SubscriptionPriceIntervalsParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionPriceIntervalsParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(SubscriptionPriceIntervalsParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override System::Uri Url(ClientOptions options) @@ -299,6 +340,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(JsonModelConverter))] @@ -349,18 +395,16 @@ public bool? CanDeferBilling /// /// A list of discounts to initialize on the price interval. /// - public IReadOnlyList? Discounts + public IReadOnlyList? Discounts { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("discounts"); + return this._rawData.GetNullableStruct>("discounts"); } init { - this._rawData.Set?>( + this._rawData.Set?>( "discounts", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -412,18 +456,18 @@ public string? Filter /// /// A list of fixed fee quantity transitions to initialize on the price interval. /// - public IReadOnlyList? FixedFeeQuantityTransitions + public IReadOnlyList? FixedFeeQuantityTransitions { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct< - ImmutableArray - >("fixed_fee_quantity_transitions"); + return this._rawData.GetNullableStruct>( + "fixed_fee_quantity_transitions" + ); } init { - this._rawData.Set?>( + this._rawData.Set?>( "fixed_fee_quantity_transitions", value == null ? null : ImmutableArray.ToImmutableArray(value) ); @@ -444,6 +488,28 @@ public double? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values (number or string). + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// The minimum amount that will be billed for this price interval for a given /// billing period. @@ -526,6 +592,7 @@ public override void Validate() item.Validate(); } _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; this.Price?.Validate(); _ = this.PriceID; @@ -534,8 +601,11 @@ public override void Validate() public Add() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Add(Add add) : base(add) { } +#pragma warning restore CS8618 public Add(IReadOnlyDictionary rawData) { @@ -614,7 +684,7 @@ public StartDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -633,14 +703,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -657,7 +727,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -668,8 +738,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -696,7 +766,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -707,8 +777,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -752,10 +822,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(StartDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(StartDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -763,7 +833,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class StartDateConverter : JsonConverter @@ -793,7 +876,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -870,7 +956,7 @@ public Discount(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -891,7 +977,7 @@ public bool TryPickAmount([NotNullWhen(true)] out Amount? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -912,7 +998,7 @@ public bool TryPickPercentage([NotNullWhen(true)] out Percentage? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -932,7 +1018,7 @@ public bool TryPickUsage([NotNullWhen(true)] out Usage? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -943,9 +1029,9 @@ public bool TryPickUsage([NotNullWhen(true)] out Usage? value) /// /// /// instance.Switch( - /// (Amount value) => {...}, - /// (Percentage value) => {...}, - /// (Usage value) => {...} + /// (Amount value) => {...}, + /// (Percentage value) => {...}, + /// (Usage value) => {...} /// ); /// /// @@ -976,7 +1062,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -987,9 +1073,9 @@ public void Switch( /// /// /// var result = instance.Match( - /// (Amount value) => {...}, - /// (Percentage value) => {...}, - /// (Usage value) => {...} + /// (Amount value) => {...}, + /// (Percentage value) => {...}, + /// (Usage value) => {...} /// ); /// /// @@ -1009,14 +1095,11 @@ public T Match( }; } - public static implicit operator global::Orb.Models.Subscriptions.Discount(Amount value) => - new(value); + public static implicit operator Discount(Amount value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Discount(Percentage value) => - new(value); + public static implicit operator Discount(Percentage value) => new(value); - public static implicit operator global::Orb.Models.Subscriptions.Discount(Usage value) => - new(value); + public static implicit operator Discount(Usage value) => new(value); /// /// Validates that the instance was constructed with a known variant and that this variant is valid @@ -1041,10 +1124,10 @@ public override void Validate() ); } - public virtual bool Equals(global::Orb.Models.Subscriptions.Discount? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(Discount? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1052,12 +1135,26 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + Amount _ => 0, + Percentage _ => 1, + Usage _ => 2, + _ => -1, + }; + } } -sealed class DiscountConverter : JsonConverter +sealed class DiscountConverter : JsonConverter { - public override global::Orb.Models.Subscriptions.Discount? Read( + public override Discount? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -1083,12 +1180,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1102,12 +1197,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1121,12 +1214,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1135,16 +1226,12 @@ JsonSerializerOptions options } default: { - return new global::Orb.Models.Subscriptions.Discount(element); + return new Discount(element); } } } - public override void Write( - Utf8JsonWriter writer, - global::Orb.Models.Subscriptions.Discount value, - JsonSerializerOptions options - ) + public override void Write(Utf8JsonWriter writer, Discount value, JsonSerializerOptions options) { JsonSerializer.Serialize(writer, value.Json, options); } @@ -1191,8 +1278,11 @@ public Amount() this.DiscountType = JsonSerializer.SerializeToElement("amount"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Amount(Amount amount) : base(amount) { } +#pragma warning restore CS8618 public Amount(IReadOnlyDictionary rawData) { @@ -1277,8 +1367,11 @@ public Percentage() this.DiscountType = JsonSerializer.SerializeToElement("percentage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Percentage(Percentage percentage) : base(percentage) { } +#pragma warning restore CS8618 public Percentage(IReadOnlyDictionary rawData) { @@ -1358,8 +1451,11 @@ public Usage() this.DiscountType = JsonSerializer.SerializeToElement("usage"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public Usage(Usage usage) : base(usage) { } +#pragma warning restore CS8618 public Usage(IReadOnlyDictionary rawData) { @@ -1440,7 +1536,7 @@ public EndDate(JsonElement element) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1459,14 +1555,14 @@ public bool TryPickDateTime([NotNullWhen(true)] out System::DateTimeOffset? valu /// /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . + /// type with a TRaw of string and a TEnum of BillingCycleRelativeDate>. /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// /// if (instance.TryPickBillingCycleRelative(out var value)) { - /// // `value` is of type `ApiEnum` + /// // `value` is of type `ApiEnum<string, BillingCycleRelativeDate>` /// Console.WriteLine(value); /// } /// @@ -1483,7 +1579,7 @@ public bool TryPickBillingCycleRelative( /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1494,8 +1590,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -1522,7 +1618,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1533,8 +1629,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -1578,10 +1674,10 @@ public override void Validate() this.Switch((_) => { }, (billingCycleRelative) => billingCycleRelative.Validate()); } - public virtual bool Equals(EndDate? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(EndDate? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1589,7 +1685,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + System::DateTimeOffset _ => 0, + ApiEnum _ => 1, + _ => -1, + }; + } } sealed class EndDateConverter : JsonConverter @@ -1619,7 +1728,10 @@ JsonSerializerOptions options try { - return new(JsonSerializer.Deserialize(element, options)); + return new( + JsonSerializer.Deserialize(element, options), + element + ); } catch (System::Exception e) when (e is JsonException || e is OrbInvalidDataException) { @@ -1636,10 +1748,7 @@ public override void Write(Utf8JsonWriter writer, EndDate? value, JsonSerializer } [JsonConverter( - typeof(JsonModelConverter< - global::Orb.Models.Subscriptions.FixedFeeQuantityTransition, - global::Orb.Models.Subscriptions.FixedFeeQuantityTransitionFromRaw - >) + typeof(JsonModelConverter) )] public sealed record class FixedFeeQuantityTransition : JsonModel { @@ -1678,10 +1787,11 @@ public override void Validate() public FixedFeeQuantityTransition() { } - public FixedFeeQuantityTransition( - global::Orb.Models.Subscriptions.FixedFeeQuantityTransition fixedFeeQuantityTransition - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + public FixedFeeQuantityTransition(FixedFeeQuantityTransition fixedFeeQuantityTransition) : base(fixedFeeQuantityTransition) { } +#pragma warning restore CS8618 public FixedFeeQuantityTransition(IReadOnlyDictionary rawData) { @@ -1696,8 +1806,8 @@ public FixedFeeQuantityTransition(IReadOnlyDictionary rawDa } #pragma warning restore CS8618 - /// - public static global::Orb.Models.Subscriptions.FixedFeeQuantityTransition FromRawUnchecked( + /// + public static FixedFeeQuantityTransition FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -1705,13 +1815,12 @@ IReadOnlyDictionary rawData } } -class FixedFeeQuantityTransitionFromRaw - : IFromRawJson +class FixedFeeQuantityTransitionFromRaw : IFromRawJson { /// - public global::Orb.Models.Subscriptions.FixedFeeQuantityTransition FromRawUnchecked( + public FixedFeeQuantityTransition FromRawUnchecked( IReadOnlyDictionary rawData - ) => global::Orb.Models.Subscriptions.FixedFeeQuantityTransition.FromRawUnchecked(rawData); + ) => FixedFeeQuantityTransition.FromRawUnchecked(rawData); } /// @@ -1768,7 +1877,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 @@ -1809,7 +1919,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 @@ -1850,7 +1961,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 @@ -1891,7 +2003,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 @@ -1932,7 +2045,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 @@ -1973,7 +2087,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 @@ -2014,7 +2129,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 @@ -2055,7 +2171,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 @@ -2096,7 +2213,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 @@ -2137,7 +2255,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 @@ -2178,7 +2297,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 @@ -2219,7 +2339,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 +2348,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newFloatingUnit: (x) => x.LicenseTypeID, + newFloatingTiered: (x) => x.LicenseTypeID, + newFloatingBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newFloatingPackage: (x) => x.LicenseTypeID, + newFloatingMatrix: (x) => x.LicenseTypeID, + newFloatingThresholdTotalAmount: (x) => x.LicenseTypeID, + newFloatingTieredPackage: (x) => x.LicenseTypeID, + newFloatingTieredWithMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedTiered: (x) => x.LicenseTypeID, + newFloatingTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newFloatingPackageWithAllocation: (x) => x.LicenseTypeID, + newFloatingUnitWithPercent: (x) => x.LicenseTypeID, + newFloatingMatrixWithAllocation: (x) => x.LicenseTypeID, + newFloatingTieredWithProration: (x) => x.LicenseTypeID, + newFloatingUnitWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedAllocation: (x) => x.LicenseTypeID, + newFloatingBulkWithProration: (x) => x.LicenseTypeID, + newFloatingGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newFloatingGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newFloatingMatrixWithDisplayName: (x) => x.LicenseTypeID, + newFloatingGroupedTieredPackage: (x) => x.LicenseTypeID, + newFloatingMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newFloatingScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newFloatingCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + 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; @@ -2401,7 +2564,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 +2603,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 +2624,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 +2645,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 +2666,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 +2687,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 +2708,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 +2729,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 +2752,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 +2775,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 +2798,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 +2821,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 +2844,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 +2867,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 +2890,7 @@ public bool TryPickNewFloatingUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2744,7 +2913,7 @@ public bool TryPickNewFloatingMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2767,7 +2936,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 +2959,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 +2982,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 +3005,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 +3028,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 +3051,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 +3074,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 +3097,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 +3120,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 +3143,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 +3166,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 +3189,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 +3212,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 +3233,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 +3279,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 +3302,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 +3323,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 +3343,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 +3354,39 @@ public bool TryPickEventOutput([NotNullWhen(true)] out PriceModelEventOutput? va /// /// /// instance.Switch( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceModelBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceModelPercent value) => {...}, - /// (PriceModelEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceModelBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceModelCumulativeGroupedAllocation value) => {...}, + /// (PriceModelDailyCreditAllowance value) => {...}, + /// (PriceModelMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3227,7 +3420,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 @@ -3319,8 +3513,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 +3537,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -3351,38 +3548,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewFloatingUnitPrice value) => {...}, - /// (NewFloatingTieredPrice value) => {...}, - /// (NewFloatingBulkPrice value) => {...}, - /// (PriceModelBulkWithFilters value) => {...}, - /// (NewFloatingPackagePrice value) => {...}, - /// (NewFloatingMatrixPrice value) => {...}, - /// (NewFloatingThresholdTotalAmountPrice value) => {...}, - /// (NewFloatingTieredPackagePrice value) => {...}, - /// (NewFloatingTieredWithMinimumPrice value) => {...}, - /// (NewFloatingGroupedTieredPrice value) => {...}, - /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, - /// (NewFloatingPackageWithAllocationPrice value) => {...}, - /// (NewFloatingUnitWithPercentPrice value) => {...}, - /// (NewFloatingMatrixWithAllocationPrice value) => {...}, - /// (NewFloatingTieredWithProrationPrice value) => {...}, - /// (NewFloatingUnitWithProrationPrice value) => {...}, - /// (NewFloatingGroupedAllocationPrice value) => {...}, - /// (NewFloatingBulkWithProrationPrice value) => {...}, - /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, - /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, - /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, - /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, - /// (NewFloatingGroupedTieredPackagePrice value) => {...}, - /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, - /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, - /// (PriceModelCumulativeGroupedAllocation value) => {...}, - /// (PriceModelMinimum value) => {...}, - /// (NewFloatingMinimumCompositePrice value) => {...}, - /// (PriceModelPercent value) => {...}, - /// (PriceModelEventOutput value) => {...} + /// (NewFloatingUnitPrice value) => {...}, + /// (NewFloatingTieredPrice value) => {...}, + /// (NewFloatingBulkPrice value) => {...}, + /// (PriceModelBulkWithFilters value) => {...}, + /// (NewFloatingPackagePrice value) => {...}, + /// (NewFloatingMatrixPrice value) => {...}, + /// (NewFloatingThresholdTotalAmountPrice value) => {...}, + /// (NewFloatingTieredPackagePrice value) => {...}, + /// (NewFloatingTieredWithMinimumPrice value) => {...}, + /// (NewFloatingGroupedTieredPrice value) => {...}, + /// (NewFloatingTieredPackageWithMinimumPrice value) => {...}, + /// (NewFloatingPackageWithAllocationPrice value) => {...}, + /// (NewFloatingUnitWithPercentPrice value) => {...}, + /// (NewFloatingMatrixWithAllocationPrice value) => {...}, + /// (NewFloatingTieredWithProrationPrice value) => {...}, + /// (NewFloatingUnitWithProrationPrice value) => {...}, + /// (NewFloatingGroupedAllocationPrice value) => {...}, + /// (NewFloatingBulkWithProrationPrice value) => {...}, + /// (NewFloatingGroupedWithProratedMinimumPrice value) => {...}, + /// (NewFloatingGroupedWithMeteredMinimumPrice value) => {...}, + /// (PriceModelGroupedWithMinMaxThresholds value) => {...}, + /// (NewFloatingMatrixWithDisplayNamePrice value) => {...}, + /// (NewFloatingGroupedTieredPackagePrice value) => {...}, + /// (NewFloatingMaxGroupTieredPackagePrice value) => {...}, + /// (NewFloatingScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewFloatingScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewFloatingCumulativeGroupedBulkPrice value) => {...}, + /// (PriceModelCumulativeGroupedAllocation value) => {...}, + /// (PriceModelDailyCreditAllowance value) => {...}, + /// (PriceModelMeteredAllowance value) => {...}, + /// (NewFloatingMinimumCompositePrice value) => {...}, + /// (PriceModelPercent value) => {...}, + /// (PriceModelEventOutput value) => {...} /// ); /// /// @@ -3431,7 +3629,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 @@ -3474,7 +3673,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), @@ -3559,7 +3759,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); @@ -3617,17 +3819,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 +3838,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewFloatingUnitPrice _ => 0, + NewFloatingTieredPrice _ => 1, + NewFloatingBulkPrice _ => 2, + PriceModelBulkWithFilters _ => 3, + NewFloatingPackagePrice _ => 4, + NewFloatingMatrixPrice _ => 5, + NewFloatingThresholdTotalAmountPrice _ => 6, + NewFloatingTieredPackagePrice _ => 7, + NewFloatingTieredWithMinimumPrice _ => 8, + NewFloatingGroupedTieredPrice _ => 9, + NewFloatingTieredPackageWithMinimumPrice _ => 10, + NewFloatingPackageWithAllocationPrice _ => 11, + NewFloatingUnitWithPercentPrice _ => 12, + NewFloatingMatrixWithAllocationPrice _ => 13, + NewFloatingTieredWithProrationPrice _ => 14, + NewFloatingUnitWithProrationPrice _ => 15, + NewFloatingGroupedAllocationPrice _ => 16, + NewFloatingBulkWithProrationPrice _ => 17, + NewFloatingGroupedWithProratedMinimumPrice _ => 18, + NewFloatingGroupedWithMeteredMinimumPrice _ => 19, + PriceModelGroupedWithMinMaxThresholds _ => 20, + NewFloatingMatrixWithDisplayNamePrice _ => 21, + NewFloatingGroupedTieredPackagePrice _ => 22, + NewFloatingMaxGroupTieredPackagePrice _ => 23, + NewFloatingScalableMatrixWithUnitPricingPrice _ => 24, + NewFloatingScalableMatrixWithTieredPricingPrice _ => 25, + NewFloatingCumulativeGroupedBulkPrice _ => 26, + PriceModelCumulativeGroupedAllocation _ => 27, + PriceModelDailyCreditAllowance _ => 28, + PriceModelMeteredAllowance _ => 29, + NewFloatingMinimumCompositePrice _ => 30, + PriceModelPercent _ => 31, + PriceModelEventOutput _ => 32, + _ => -1, + }; + } } sealed class PriceModelConverter : JsonConverter @@ -3669,12 +3916,10 @@ JsonSerializerOptions 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 +3936,10 @@ JsonSerializerOptions 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 +3956,10 @@ JsonSerializerOptions 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 +3976,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3757,12 +3996,10 @@ JsonSerializerOptions 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 +4016,10 @@ JsonSerializerOptions 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 +4037,10 @@ JsonSerializerOptions 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 +4057,10 @@ JsonSerializerOptions 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 +4078,10 @@ JsonSerializerOptions 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 +4098,10 @@ JsonSerializerOptions 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 +4119,10 @@ JsonSerializerOptions 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 +4140,10 @@ JsonSerializerOptions 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 +4160,10 @@ JsonSerializerOptions 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 +4181,10 @@ JsonSerializerOptions 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 +4202,10 @@ JsonSerializerOptions 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 +4223,10 @@ JsonSerializerOptions 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 +4244,10 @@ JsonSerializerOptions 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 +4265,10 @@ JsonSerializerOptions 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 +4286,10 @@ JsonSerializerOptions 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 +4307,10 @@ JsonSerializerOptions 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 +4328,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4144,12 +4349,10 @@ JsonSerializerOptions 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 +4370,10 @@ JsonSerializerOptions 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 +4391,10 @@ JsonSerializerOptions 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 +4412,10 @@ JsonSerializerOptions 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 +4433,10 @@ JsonSerializerOptions 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 +4454,10 @@ JsonSerializerOptions 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 +4475,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 +4535,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4348,12 +4555,10 @@ JsonSerializerOptions 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 +4575,10 @@ JsonSerializerOptions 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 +4830,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +4891,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -4683,8 +4900,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 +5006,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 +5093,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 +5182,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 +5337,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 +5358,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5378,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5389,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5190,7 +5419,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5430,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5251,10 +5480,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 +5491,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5539,10 @@ JsonSerializerOptions 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 +5559,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5579,6 +5817,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5627,6 +5878,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -5635,10 +5887,13 @@ public PriceModelGroupedWithMinMaxThresholds() this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelGroupedWithMinMaxThresholds( PriceModelGroupedWithMinMaxThresholds priceModelGroupedWithMinMaxThresholds ) : base(priceModelGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public PriceModelGroupedWithMinMaxThresholds(IReadOnlyDictionary rawData) { @@ -5808,10 +6063,13 @@ public override void Validate() public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base(priceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig) { } +#pragma warning restore CS8618 public PriceModelGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -5896,7 +6154,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 +6175,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6195,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6206,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5978,7 +6236,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6247,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6039,10 +6297,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelGroupedWithMinMaxThresholdsConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6050,7 +6308,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -6085,12 +6356,10 @@ JsonSerializerOptions 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 +6376,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6367,6 +6634,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6415,6 +6695,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -6423,10 +6704,13 @@ public PriceModelCumulativeGroupedAllocation() this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelCumulativeGroupedAllocation( PriceModelCumulativeGroupedAllocation priceModelCumulativeGroupedAllocation ) : base(priceModelCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public PriceModelCumulativeGroupedAllocation(IReadOnlyDictionary rawData) { @@ -6596,10 +6880,13 @@ public override void Validate() public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base(priceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig) { } +#pragma warning restore CS8618 public PriceModelCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -6684,7 +6971,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 +6992,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7012,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7023,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6766,7 +7053,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7064,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6827,10 +7114,10 @@ public override void Validate() this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } - public virtual bool Equals(PriceModelCumulativeGroupedAllocationConversionRateConfig? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals(PriceModelCumulativeGroupedAllocationConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6838,7 +7125,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class PriceModelCumulativeGroupedAllocationConversionRateConfigConverter @@ -6873,12 +7173,10 @@ JsonSerializerOptions 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 +7193,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6924,20 +7220,25 @@ JsonSerializerOptions options } } -[JsonConverter(typeof(JsonModelConverter))] -public sealed record class PriceModelMinimum : JsonModel +[JsonConverter( + typeof(JsonModelConverter< + PriceModelDailyCreditAllowance, + PriceModelDailyCreditAllowanceFromRaw + >) +)] +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>( - "cadence" - ); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); } init { this._rawData.Set("cadence", value); } } @@ -6956,29 +7257,31 @@ public required string Currency } /// - /// The id of the item the price will be associated with. + /// Configuration for daily_credit_allowance pricing /// - public required string ItemID + public required PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("daily_credit_allowance_config", value); } } /// - /// Configuration for minimum pricing + /// The id of the item the price will be associated with. /// - public required PriceModelMinimumMinimumConfig 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); } } /// @@ -7066,12 +7369,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public PriceModelMinimumConversionRateConfig? ConversionRateConfig + public PriceModelDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -7149,9 +7452,963 @@ 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 string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `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.DailyCreditAllowanceConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) + { + 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 PriceModelDailyCreditAllowance() + { + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelDailyCreditAllowance( + PriceModelDailyCreditAllowance priceModelDailyCreditAllowance + ) + : base(priceModelDailyCreditAllowance) { } +#pragma warning restore CS8618 + + public PriceModelDailyCreditAllowance(IReadOnlyDictionary rawData) + { + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelDailyCreditAllowance(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelDailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelDailyCreditAllowanceFromRaw : IFromRawJson +{ + /// + public PriceModelDailyCreditAllowance FromRawUnchecked( + IReadOnlyDictionary rawData + ) => PriceModelDailyCreditAllowance.FromRawUnchecked(rawData); +} + +/// +/// The cadence to bill for this price on. +/// +[JsonConverter(typeof(PriceModelDailyCreditAllowanceCadenceConverter))] +public enum PriceModelDailyCreditAllowanceCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} + +sealed class PriceModelDailyCreditAllowanceCadenceConverter + : JsonConverter +{ + public override PriceModelDailyCreditAllowanceCadence Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + return JsonSerializer.Deserialize(ref reader, options) switch + { + "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, + PriceModelDailyCreditAllowanceCadence value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize( + writer, + value switch + { + 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)) + ), + }, + options + ); + } +} + +/// +/// Configuration for daily_credit_allowance pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig, + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + >) +)] +public sealed record class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfig : 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 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 + { + 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 PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue priceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + ) + : base(priceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue) { } +#pragma warning restore CS8618 + + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} + +class PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson +{ + /// + public PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + PriceModelDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( + rawData + ); +} + +[JsonConverter(typeof(PriceModelDailyCreditAllowanceConversionRateConfigConverter))] +public record class PriceModelDailyCreditAllowanceConversionRateConfig : ModelBase +{ + public object? Value { get; } = null; + + JsonElement? _element = null; + + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public PriceModelDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public PriceModelDailyCreditAllowanceConversionRateConfig(JsonElement element) + { + this._element = element; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickUnit(out var value)) { + /// // `value` is of type `SharedUnitConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? value) + { + value = this.Value as SharedUnitConversionRateConfig; + return value != null; + } + + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickTiered(out var value)) { + /// // `value` is of type `SharedTieredConversionRateConfig` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConfig? value) + { + value = this.Value as SharedTieredConversionRateConfig; + return value != null; + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// instance.Switch( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public void Switch( + System::Action unit, + System::Action tiered + ) + { + switch (this.Value) + { + case SharedUnitConversionRateConfig value: + unit(value); + break; + case SharedTieredConversionRateConfig value: + tiered(value); + break; + default: + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" + ); + } + } + + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with and + /// returns its result. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you don't need your function parameters to return a value. + /// + /// + /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data + /// that doesn't match any variant's expected shape). + /// + /// + /// + /// + /// var result = instance.Match( + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} + /// ); + /// + /// + /// + public T Match( + System::Func unit, + System::Func tiered + ) + { + return this.Value switch + { + SharedUnitConversionRateConfig value => unit(value), + SharedTieredConversionRateConfig value => tiered(value), + _ => throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" + ), + }; + } + + public static implicit operator PriceModelDailyCreditAllowanceConversionRateConfig( + SharedUnitConversionRateConfig value + ) => new(value); + + public static implicit operator PriceModelDailyCreditAllowanceConversionRateConfig( + SharedTieredConversionRateConfig value + ) => new(value); + + /// + /// Validates that the instance was constructed with a known variant and that this variant is valid + /// (based on its own Validate method). + /// + /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). + /// + /// + /// Thrown when the instance does not pass validation. + /// + /// + public override void Validate() + { + if (this.Value == null) + { + throw new OrbInvalidDataException( + "Data did not match any variant of PriceModelDailyCreditAllowanceConversionRateConfig" + ); + } + this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); + } + + public virtual bool Equals(PriceModelDailyCreditAllowanceConversionRateConfig? other) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); + + public override int GetHashCode() + { + return 0; + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } +} + +sealed class PriceModelDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter +{ + public override PriceModelDailyCreditAllowanceConversionRateConfig? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options + ) + { + var element = JsonSerializer.Deserialize(ref reader, options); + string? conversionRateType; + try + { + 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 PriceModelDailyCreditAllowanceConversionRateConfig(element); + } + } + } + + public override void Write( + Utf8JsonWriter writer, + PriceModelDailyCreditAllowanceConversionRateConfig value, + JsonSerializerOptions options + ) + { + JsonSerializer.Serialize(writer, value.Json, options); + } +} + +[JsonConverter( + typeof(JsonModelConverter) +)] +public sealed record class PriceModelMeteredAllowance : JsonModel +{ + /// + /// The cadence to bill for this price on. + /// + public required ApiEnum Cadence + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass< + ApiEnum + >("cadence"); + } + init { this._rawData.Set("cadence", value); } + } + + /// + /// An ISO 4217 currency string for which this price is billed in. + /// + public required string Currency + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("currency"); + } + init { this._rawData.Set("currency", value); } + } + + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } + } + + /// + /// Configuration for metered_allowance pricing + /// + public required PriceModelMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); + } + init { this._rawData.Set("metered_allowance_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 PriceModelMeteredAllowanceConversionRateConfig? 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 { @@ -7175,8 +8432,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 +8453,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 +8492,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 +8514,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 +8525,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 +8545,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 +8561,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 +8666,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 +8742,7 @@ public JsonElement Json } } - public PriceModelMinimumConversionRateConfig( + public PriceModelMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -7415,7 +8751,7 @@ public PriceModelMinimumConversionRateConfig( this._element = element; } - public PriceModelMinimumConversionRateConfig( + public PriceModelMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -7424,7 +8760,7 @@ public PriceModelMinimumConversionRateConfig( this._element = element; } - public PriceModelMinimumConversionRateConfig(JsonElement element) + public PriceModelMeteredAllowanceConversionRateConfig(JsonElement element) { this._element = element; } @@ -7433,7 +8769,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 +8790,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8810,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8821,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7506,7 +8842,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 +8851,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8862,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7542,16 +8878,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 +8906,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 +8923,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 +8971,10 @@ JsonSerializerOptions 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 +8991,10 @@ JsonSerializerOptions 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 +9003,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 +9242,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +9298,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -7948,8 +9307,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 +9435,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 +9525,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 +9546,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9566,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9577,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8242,7 +9607,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9618,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8303,10 +9668,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 +9679,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +9727,10 @@ JsonSerializerOptions 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 +9747,10 @@ JsonSerializerOptions 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 +10000,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +10061,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; } @@ -8682,8 +10070,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 +10230,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 +10321,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 +10342,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10362,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10373,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9009,7 +10403,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10414,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9070,10 +10464,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 +10475,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +10523,10 @@ JsonSerializerOptions 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 +10543,10 @@ JsonSerializerOptions 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 +10655,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 +10756,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 +10775,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 +10799,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 +10810,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9434,7 +10840,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10851,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -9499,10 +10905,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 +10916,20 @@ public override int GetHashCode() } 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 +10960,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 +11086,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 +11107,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 +11128,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 +11149,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 +11170,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 +11190,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 +11201,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 +11246,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11257,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 +11334,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 +11345,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 +11396,10 @@ JsonSerializerOptions 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 +11416,10 @@ JsonSerializerOptions 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 +11436,10 @@ JsonSerializerOptions 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 +11453,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 +11470,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 +11548,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 +11567,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 +11591,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 +11602,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10204,7 +11632,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11643,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10269,10 +11697,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 +11708,20 @@ public override int GetHashCode() } 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 +11752,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 +11873,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 +11953,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 +12043,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 +12062,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 +12086,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 +12097,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10655,7 +12125,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +12136,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10711,10 +12181,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 +12192,20 @@ public override int GetHashCode() } 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 +12235,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 +12301,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 +12385,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 +12404,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 +12428,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 +12439,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -10980,7 +12469,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +12480,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11039,10 +12528,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 +12539,20 @@ public override int GetHashCode() } 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 +12582,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 +12667,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 +12753,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 +12772,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 +12796,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 +12807,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11329,7 +12837,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +12848,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11392,10 +12900,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 +12911,20 @@ public override int GetHashCode() } 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 +12954,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 +13023,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 +13042,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 +13066,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 +13077,8 @@ public bool TryPickBillingCycleRelative( /// /// /// instance.Switch( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11583,7 +13107,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +13118,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (System::DateTimeOffset value) => {...}, - /// (ApiEnum value) => {...} + /// (System::DateTimeOffset value) => {...}, + /// (ApiEnum<string, BillingCycleRelativeDate> value) => {...} /// ); /// /// @@ -11646,10 +13170,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 +13181,20 @@ public override int GetHashCode() } 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 +13224,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..a4600038d 100644 --- a/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs +++ b/src/Orb/Models/Subscriptions/SubscriptionSchedulePlanChangeParams.cs @@ -50,9 +50,9 @@ namespace Orb.Models.Subscriptions; /// subscription when you schedule the plan change. This is useful when a customer /// has prices that differ from the default prices for a specific plan. /// -/// This feature is only available for accounts that have migrated to -/// Subscription Overrides Version 2. You can find your Subscription Overrides Version -/// at the bottom of your [Plans page](https://app.withorb.com/plans) +/// <Note> This feature is only available for accounts that have migrated +/// to Subscription Overrides Version 2. You can find your Subscription Overrides +/// Version at the bottom of your [Plans page](https://app.withorb.com/plans) </Note> /// /// ### Adding Prices /// @@ -143,8 +143,8 @@ namespace Orb.Models.Subscriptions; /// /// ## Price overrides (DEPRECATED) /// -/// Price overrides are being phased out in favor adding/removing/replacing -/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) +/// <Note> Price overrides are being phased out in favor adding/removing/replacing +/// prices. (See [Customize your customer's subscriptions](/api-reference/subscription/schedule-plan-change)) </Note> /// /// Price overrides are used to update some or all prices in a plan for the /// specific subscription being created. This is useful when a new customer has negotiated @@ -169,8 +169,12 @@ namespace Orb.Models.Subscriptions; /// ## Prorations for in-advance fees By default, Orb calculates the prorated /// difference in any fixed fees when making a plan change, adjusting the customer /// balance as needed. For details on this behavior, see [Modifying subscriptions](/product-catalog/modifying-subscriptions#prorations-for-in-advance-fees). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// -public sealed record class SubscriptionSchedulePlanChangeParams : ParamsBase +public record class SubscriptionSchedulePlanChangeParams : ParamsBase { readonly JsonDictionary _rawBodyData = new(); public IReadOnlyDictionary RawBodyData @@ -613,6 +617,8 @@ public IReadOnlyList? UsageCustomerIds public SubscriptionSchedulePlanChangeParams() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParams( SubscriptionSchedulePlanChangeParams subscriptionSchedulePlanChangeParams ) @@ -622,6 +628,7 @@ SubscriptionSchedulePlanChangeParams subscriptionSchedulePlanChangeParams this._rawBodyData = new(subscriptionSchedulePlanChangeParams._rawBodyData); } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParams( IReadOnlyDictionary rawHeaderData, @@ -639,27 +646,61 @@ IReadOnlyDictionary rawBodyData SubscriptionSchedulePlanChangeParams( FrozenDictionary rawHeaderData, FrozenDictionary rawQueryData, - FrozenDictionary rawBodyData + FrozenDictionary rawBodyData, + string subscriptionID ) { this._rawHeaderData = new(rawHeaderData); this._rawQueryData = new(rawQueryData); this._rawBodyData = new(rawBodyData); + this.SubscriptionID = subscriptionID; } #pragma warning restore CS8618 - /// + /// public static SubscriptionSchedulePlanChangeParams FromRawUnchecked( IReadOnlyDictionary rawHeaderData, IReadOnlyDictionary rawQueryData, - IReadOnlyDictionary rawBodyData + IReadOnlyDictionary rawBodyData, + string subscriptionID ) { return new( FrozenDictionary.ToFrozenDictionary(rawHeaderData), FrozenDictionary.ToFrozenDictionary(rawQueryData), - FrozenDictionary.ToFrozenDictionary(rawBodyData) + FrozenDictionary.ToFrozenDictionary(rawBodyData), + subscriptionID + ); + } + + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue( + new Dictionary() + { + ["SubscriptionID"] = JsonSerializer.SerializeToElement(this.SubscriptionID), + ["HeaderData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawHeaderData.Freeze()) + ), + ["QueryData"] = FriendlyJsonPrinter.PrintValue( + JsonSerializer.SerializeToElement(this._rawQueryData.Freeze()) + ), + ["BodyData"] = FriendlyJsonPrinter.PrintValue(this._rawBodyData.Freeze()), + } + ), + ModelBase.ToStringSerializerOptions ); + + public virtual bool Equals(SubscriptionSchedulePlanChangeParams? other) + { + if (other == null) + { + return false; + } + return (this.SubscriptionID?.Equals(other.SubscriptionID) ?? other.SubscriptionID == null) + && this._rawHeaderData.Equals(other._rawHeaderData) + && this._rawQueryData.Equals(other._rawQueryData) + && this._rawBodyData.Equals(other._rawBodyData); } public override System::Uri Url(ClientOptions options) @@ -690,6 +731,11 @@ internal override void AddHeadersToRequest(HttpRequestMessage request, ClientOpt ParamsBase.AddHeaderElementToRequest(request, item.Key, item.Value); } } + + public override int GetHashCode() + { + return 0; + } } [JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsChangeOptionConverter))] @@ -818,10 +864,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddAdjustment() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddAdjustment( SubscriptionSchedulePlanChangeParamsAddAdjustment subscriptionSchedulePlanChangeParamsAddAdjustment ) : base(subscriptionSchedulePlanChangeParamsAddAdjustment) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddAdjustment( IReadOnlyDictionary rawData @@ -968,7 +1017,7 @@ public SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment(JsonElement e /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -989,7 +1038,7 @@ public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDi /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1010,7 +1059,7 @@ public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? va /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1031,7 +1080,7 @@ public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1052,7 +1101,7 @@ public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -1072,7 +1121,7 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you need your function parameters to return something. /// /// @@ -1083,11 +1132,11 @@ public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) /// /// /// instance.Switch( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1128,7 +1177,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick method(s) if you don't need to handle every variant, or /// if you don't need your function parameters to return a value. /// /// @@ -1139,11 +1188,11 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewPercentageDiscount value) => {...}, - /// (NewUsageDiscount value) => {...}, - /// (NewAmountDiscount value) => {...}, - /// (NewMinimum value) => {...}, - /// (NewMaximum value) => {...} + /// (NewPercentageDiscount value) => {...}, + /// (NewUsageDiscount value) => {...}, + /// (NewAmountDiscount value) => {...}, + /// (NewMinimum value) => {...}, + /// (NewMaximum value) => {...} /// ); /// /// @@ -1216,10 +1265,12 @@ public override void Validate() ); } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment? other) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustment? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -1227,7 +1278,23 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddAdjustmentAdjustmentConverter @@ -1262,12 +1329,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1284,12 +1349,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1306,12 +1369,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1325,12 +1386,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1344,12 +1403,10 @@ JsonSerializerOptions options var deserialized = JsonSerializer.Deserialize(element, options); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -1457,6 +1514,28 @@ public string? MaximumAmount init { this._rawData.Set("maximum_amount", value); } } + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>( + "metric_parameter_overrides" + ); + } + init + { + this._rawData.Set?>( + "metric_parameter_overrides", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } + } + /// /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount /// for this price. @@ -1539,6 +1618,7 @@ public override void Validate() _ = this.EndDate; _ = this.ExternalPriceID; _ = this.MaximumAmount; + _ = this.MetricParameterOverrides; _ = this.MinimumAmount; _ = this.PlanPhaseOrder; this.Price?.Validate(); @@ -1548,10 +1628,13 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPrice() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPrice( SubscriptionSchedulePlanChangeParamsAddPrice subscriptionSchedulePlanChangeParamsAddPrice ) : base(subscriptionSchedulePlanChangeParamsAddPrice) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPrice( IReadOnlyDictionary rawData @@ -1640,7 +1723,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 @@ -1681,7 +1765,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 @@ -1722,7 +1807,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 @@ -1763,7 +1849,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 @@ -1804,7 +1891,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 @@ -1845,7 +1933,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 @@ -1886,7 +1975,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 @@ -1929,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 @@ -1970,7 +2061,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 @@ -2011,7 +2103,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 @@ -2052,7 +2145,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 @@ -2094,7 +2188,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 +2197,48 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration } } + public string? LicenseTypeID + { + get + { + return Match( + newSubscriptionUnit: (x) => x.LicenseTypeID, + newSubscriptionTiered: (x) => x.LicenseTypeID, + newSubscriptionBulk: (x) => x.LicenseTypeID, + bulkWithFilters: (x) => x.LicenseTypeID, + newSubscriptionPackage: (x) => x.LicenseTypeID, + newSubscriptionMatrix: (x) => x.LicenseTypeID, + newSubscriptionThresholdTotalAmount: (x) => x.LicenseTypeID, + newSubscriptionTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionTieredWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedTiered: (x) => x.LicenseTypeID, + newSubscriptionTieredPackageWithMinimum: (x) => x.LicenseTypeID, + newSubscriptionPackageWithAllocation: (x) => x.LicenseTypeID, + newSubscriptionUnitWithPercent: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithAllocation: (x) => x.LicenseTypeID, + tieredWithProration: (x) => x.LicenseTypeID, + newSubscriptionUnitWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedAllocation: (x) => x.LicenseTypeID, + newSubscriptionBulkWithProration: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.LicenseTypeID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.LicenseTypeID, + groupedWithMinMaxThresholds: (x) => x.LicenseTypeID, + newSubscriptionMatrixWithDisplayName: (x) => x.LicenseTypeID, + newSubscriptionGroupedTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionMaxGroupTieredPackage: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.LicenseTypeID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.LicenseTypeID, + newSubscriptionCumulativeGroupedBulk: (x) => x.LicenseTypeID, + cumulativeGroupedAllocation: (x) => x.LicenseTypeID, + dailyCreditAllowance: (x) => x.LicenseTypeID, + meteredAllowance: (x) => x.LicenseTypeID, + newSubscriptionMinimumComposite: (x) => x.LicenseTypeID, + percent: (x) => x.LicenseTypeID, + eventOutput: (x) => x.LicenseTypeID + ); + } + } + public string? ReferenceID { get @@ -2135,7 +2272,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 @@ -2396,7 +2534,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 +2587,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 +2608,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 +2631,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 +2652,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 +2676,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 +2699,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 +2722,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 +2745,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 +2768,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 +2791,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 +2814,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 +2837,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 +2860,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 +2883,7 @@ public bool TryPickNewSubscriptionUnitWithPercent( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2759,7 +2906,7 @@ public bool TryPickNewSubscriptionMatrixWithAllocation( /// Returns true and sets the out parameter if the instance was constructed with a variant of /// type . /// - /// Consider using or if you need to handle every variant. + /// Consider using or if you need to handle every variant. /// /// /// @@ -2783,7 +2930,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 +2953,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 +2976,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 +2999,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 +3022,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 +3045,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 +3071,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 +3094,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 +3117,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 +3140,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 +3163,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 +3186,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 +3209,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 +3233,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 +3283,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 +3306,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 +3329,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 +3351,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 +3362,39 @@ public bool TryPickEventOutput( /// /// /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3255,7 +3428,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 @@ -3347,8 +3521,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 +3547,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +3558,39 @@ public void Switch( /// /// /// var result = instance.Match( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} + /// (NewSubscriptionUnitPrice value) => {...}, + /// (NewSubscriptionTieredPrice value) => {...}, + /// (NewSubscriptionBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters value) => {...}, + /// (NewSubscriptionPackagePrice value) => {...}, + /// (NewSubscriptionMatrixPrice value) => {...}, + /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, + /// (NewSubscriptionTieredPackagePrice value) => {...}, + /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedTieredPrice value) => {...}, + /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, + /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, + /// (NewSubscriptionUnitWithPercentPrice value) => {...}, + /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration value) => {...}, + /// (NewSubscriptionUnitWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedAllocationPrice value) => {...}, + /// (NewSubscriptionBulkWithProrationPrice value) => {...}, + /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, + /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds value) => {...}, + /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, + /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, + /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, + /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, + /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance value) => {...}, + /// (NewSubscriptionMinimumCompositePrice value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePricePercent value) => {...}, + /// (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput value) => {...} /// ); /// /// @@ -3494,7 +3672,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 @@ -3553,7 +3738,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( @@ -3678,7 +3866,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( @@ -3749,17 +3941,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 +3960,51 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + NewSubscriptionUnitPrice _ => 0, + NewSubscriptionTieredPrice _ => 1, + NewSubscriptionBulkPrice _ => 2, + SubscriptionSchedulePlanChangeParamsAddPricePriceBulkWithFilters _ => 3, + NewSubscriptionPackagePrice _ => 4, + NewSubscriptionMatrixPrice _ => 5, + NewSubscriptionThresholdTotalAmountPrice _ => 6, + NewSubscriptionTieredPackagePrice _ => 7, + NewSubscriptionTieredWithMinimumPrice _ => 8, + NewSubscriptionGroupedTieredPrice _ => 9, + NewSubscriptionTieredPackageWithMinimumPrice _ => 10, + NewSubscriptionPackageWithAllocationPrice _ => 11, + NewSubscriptionUnitWithPercentPrice _ => 12, + NewSubscriptionMatrixWithAllocationPrice _ => 13, + SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds _ => 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation _ => 27, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance _ => 28, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance _ => 29, + NewSubscriptionMinimumCompositePrice _ => 30, + SubscriptionSchedulePlanChangeParamsAddPricePricePercent _ => 31, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput _ => 32, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceConverter @@ -3802,12 +4039,10 @@ JsonSerializerOptions 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 +4059,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -3846,12 +4079,10 @@ JsonSerializerOptions 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 +4100,10 @@ JsonSerializerOptions 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 +4120,10 @@ JsonSerializerOptions 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 +4140,10 @@ JsonSerializerOptions 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 +4161,10 @@ JsonSerializerOptions 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 +4182,10 @@ JsonSerializerOptions 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 +4203,10 @@ JsonSerializerOptions 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 +4224,10 @@ JsonSerializerOptions 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 +4245,10 @@ JsonSerializerOptions 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 +4266,10 @@ JsonSerializerOptions 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 +4287,10 @@ JsonSerializerOptions 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 +4308,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4120,12 +4329,10 @@ JsonSerializerOptions 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 +4350,10 @@ JsonSerializerOptions 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 +4371,10 @@ JsonSerializerOptions 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 +4392,10 @@ JsonSerializerOptions 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 +4413,10 @@ JsonSerializerOptions 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 +4434,10 @@ JsonSerializerOptions 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 +4455,10 @@ JsonSerializerOptions 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 +4476,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -4304,12 +4497,10 @@ JsonSerializerOptions 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 +4518,10 @@ JsonSerializerOptions 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 +4539,10 @@ JsonSerializerOptions 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 +4560,10 @@ JsonSerializerOptions 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 +4581,10 @@ JsonSerializerOptions 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 +4602,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 +4665,10 @@ JsonSerializerOptions 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 +4686,10 @@ JsonSerializerOptions 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 +4707,10 @@ JsonSerializerOptions 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 +4973,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +5048,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -4850,10 +5058,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 +5171,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 +5267,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 +5363,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 +5544,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 +5565,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +5585,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +5596,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5406,7 +5626,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +5637,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -5469,10 +5689,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 +5700,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +5748,10 @@ JsonSerializerOptions 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 +5768,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -5807,6 +6036,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -5869,6 +6111,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -5878,10 +6121,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration() this.ModelType = JsonSerializer.SerializeToElement("tiered_with_proration"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProration( IReadOnlyDictionary rawData @@ -6042,12 +6288,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfig( IReadOnlyDictionary rawData @@ -6144,12 +6393,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationTieredWithProrationConfigTier( IReadOnlyDictionary rawData @@ -6239,7 +6491,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 +6512,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +6532,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +6543,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6321,7 +6573,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +6584,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -6384,10 +6636,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -6395,7 +6647,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceTieredWithProrationConversionRateConfigConverter @@ -6430,12 +6695,10 @@ JsonSerializerOptions 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 +6715,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -6722,6 +6983,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -6784,6 +7058,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -6793,10 +7068,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresho this.ModelType = JsonSerializer.SerializeToElement("grouped_with_min_max_thresholds"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholds( IReadOnlyDictionary rawData @@ -6991,12 +7269,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( IReadOnlyDictionary rawData @@ -7086,7 +7367,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 +7388,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +7408,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +7419,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7168,7 +7449,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +7460,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -7231,10 +7512,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -7242,7 +7523,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceGroupedWithMinMaxThresholdsConversionRateConfigConverter @@ -7277,12 +7571,10 @@ JsonSerializerOptions 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 +7591,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -7569,6 +7859,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -7631,6 +7934,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -7640,10 +7944,13 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocat this.ModelType = JsonSerializer.SerializeToElement("cumulative_grouped_allocation"); } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation ) : base(subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocation( IReadOnlyDictionary rawData @@ -7838,12 +8145,15 @@ public override void Validate() public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig() { } +#pragma warning disable CS8618 + [SetsRequiredMembers] public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) : base( subscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig ) { } +#pragma warning restore CS8618 public SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( IReadOnlyDictionary rawData @@ -7933,7 +8243,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 +8264,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +8284,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +8295,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8015,7 +8325,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +8336,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8078,10 +8388,10 @@ public override void Validate() public virtual bool Equals( SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfig? other - ) - { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); - } + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -8089,7 +8399,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); + + int VariantIndex() + { + return this.Value switch + { + SharedUnitConversionRateConfig _ => 0, + SharedTieredConversionRateConfig _ => 1, + _ => -1, + }; + } } sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceCumulativeGroupedAllocationConversionRateConfigConverter @@ -8124,12 +8447,10 @@ JsonSerializerOptions 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 +8467,10 @@ JsonSerializerOptions options ); if (deserialized != null) { - deserialized.Validate(); return new(deserialized, element); } } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) + catch (JsonException) { // ignore } @@ -8179,56 +8498,60 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } } /// - /// The id of the item the price will be associated with. + /// Configuration for daily_credit_allowance pricing /// - public required string ItemID + public required SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig DailyCreditAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("item_id"); + return this._rawData.GetNotNullClass( + "daily_credit_allowance_config" + ); } - init { this._rawData.Set("item_id", value); } + init { this._rawData.Set("daily_credit_allowance_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 +8639,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -8412,6 +8735,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +8787,14 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); + this.DailyCreditAllowanceConfig.Validate(); _ = this.ItemID; - this.MinimumConfig.Validate(); - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("minimum"))) + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("daily_credit_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } @@ -8469,32 +8810,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum() + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum subscriptionSchedulePlanChangeParamsAddPricePriceMinimum +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimum) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("minimum"); + this.ModelType = JsonSerializer.SerializeToElement("daily_credit_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance( FrozenDictionary rawData ) { @@ -8502,8 +8847,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -8511,20 +8856,25 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimum.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowance.FromRawUnchecked( + rawData + ); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence { Annual, SemiAnnual, @@ -8534,10 +8884,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8545,21 +8895,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence value, JsonSerializerOptions options ) { @@ -8567,16 +8921,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -8587,66 +8943,124 @@ JsonSerializerOptions options } /// -/// Configuration for minimum pricing +/// Configuration for daily_credit_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig : JsonModel { /// - /// The minimum amount to apply + /// Credits granted per day. Lose-it-or-use-it; does not roll over. /// - public required string MinimumAmount + public required string DailyAllowance { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("minimum_amount"); + return this._rawData.GetNotNullClass("daily_allowance"); } - init { this._rawData.Set("minimum_amount", 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); } } /// - /// If true, subtotals from this price are prorated based on the service period + /// One or two event property values to evaluate matrix groups by /// - public bool? Prorated + public required IReadOnlyList Dimensions { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("prorated"); + return this._rawData.GetNotNullStruct>("dimensions"); } init { - if (value == null) - { - return; - } + 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); } + } - this._rawData.Set("prorated", 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.MinimumAmount; - _ = this.Prorated; + _ = this.DailyAllowance; + _ = this.DefaultUnitAmount; + _ = this.Dimensions; + _ = this.EventDayProperty; + foreach (var item in this.MatrixValues) + { + item.Validate(); + } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig() + { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig) { } + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -8655,7 +9069,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig( FrozenDictionary rawData ) { @@ -8663,40 +9077,134 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} + +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfig.FromRawUnchecked( + rawData + ); +} + +/// +/// Per-dimension credit price for the daily credit allowance model. +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue + : 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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue() + { } + +#pragma warning disable CS8618 [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig( - string minimumAmount + 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 ) - : this() { - this.MinimumAmount = minimumAmount; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValueFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumMinimumConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -8714,7 +9222,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -8723,7 +9231,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -8732,7 +9240,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( JsonElement element ) { @@ -8743,7 +9251,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 +9272,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +9292,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +9303,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8816,7 +9324,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ); } } @@ -8825,7 +9333,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +9344,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -8852,16 +9360,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -8880,18 +9388,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? 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() { @@ -8899,13 +9407,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 SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -8934,12 +9455,10 @@ JsonSerializerOptions 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 +9475,10 @@ JsonSerializerOptions 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 +9487,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig( element ); } @@ -8979,7 +9496,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -8989,25 +9506,29 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercent, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance + : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence + > >("cadence"); } init { this._rawData.Set("cadence", value); } @@ -9027,44 +9548,44 @@ public required string ItemID } /// - /// The pricing model type + /// Configuration for metered_allowance pricing /// - public JsonElement ModelType + public required SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig MeteredAllowanceConfig { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("model_type"); + return this._rawData.GetNotNullClass( + "metered_allowance_config" + ); } - init { this._rawData.Set("model_type", value); } + init { this._rawData.Set("metered_allowance_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 percent pricing + /// The name of the price. /// - public required SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig 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); } } /// @@ -9126,12 +9647,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -9222,6 +9743,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/value pairs for the resource. Individual keys can be removed /// by setting the value to `null`, and the entire metadata mapping can be cleared @@ -9262,12 +9796,17 @@ public override void Validate() { this.Cadence.Validate(); _ = this.ItemID; - if (!JsonElement.DeepEquals(this.ModelType, JsonSerializer.SerializeToElement("percent"))) + this.MeteredAllowanceConfig.Validate(); + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("metered_allowance") + ) + ) { throw new OrbInvalidDataException("Invalid value given for constant"); } _ = this.Name; - this.PercentConfig.Validate(); _ = this.BillableMetricID; _ = this.BilledInAdvance; this.BillingCycleConfiguration?.Validate(); @@ -9279,32 +9818,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance() { - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( - SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("percent"); + this.ModelType = JsonSerializer.SerializeToElement("metered_allowance"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance( FrozenDictionary rawData ) { @@ -9312,8 +9855,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -9321,20 +9864,23 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); + ) => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowance.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] -public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence { Annual, SemiAnnual, @@ -9344,10 +9890,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9355,21 +9901,25 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, + "annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, - "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, - "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime, + "custom" => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence value, JsonSerializerOptions options ) { @@ -9377,16 +9927,18 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Annual => + "annual", + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceCadence.Custom => + "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -9397,44 +9949,141 @@ JsonSerializerOptions options } /// -/// Configuration for percent pricing +/// Configuration for metered_allowance pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig : JsonModel { /// - /// What percent of the component subtotals to charge + /// 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 double Percent + public required string AllowanceGroupingValue { get { this._rawData.Freeze(); - return this._rawData.GetNotNullStruct("percent"); + 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); } - init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.Percent; + _ = this.AllowanceGroupingValue; + _ = this.ConsumptionGroupingValue; + _ = this.GroupingKey; + _ = this.UnitAmount; + _ = this.AllowanceDisplayName; + _ = this.ConsumptionDisplayName; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig() + { } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } + : base( + subscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig + ) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( IReadOnlyDictionary rawData ) { @@ -9443,7 +10092,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig( FrozenDictionary rawData ) { @@ -9451,38 +10100,31 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) - : this() - { - this.Percent = percent; - } } -class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceMeteredAllowanceConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -9500,7 +10142,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -9509,7 +10151,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -9518,7 +10160,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateCon this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -9529,7 +10171,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 +10192,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +10212,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +10223,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9602,7 +10244,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ); } } @@ -9611,7 +10253,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +10264,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -9638,16 +10280,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 SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -9666,18 +10308,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 SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? 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() { @@ -9685,13 +10327,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 SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -9720,12 +10375,10 @@ JsonSerializerOptions 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 +10395,10 @@ JsonSerializerOptions 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 +10407,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig( element ); } @@ -9765,7 +10416,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -9775,45 +10426,30 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePricePercent, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercent : JsonModel { /// /// The cadence to bill for this price on. /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence > Cadence { get { this._rawData.Freeze(); return this._rawData.GetNotNullClass< - ApiEnum + ApiEnum >("cadence"); } init { this._rawData.Set("cadence", value); } } - /// - /// Configuration for event_output pricing - /// - public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig - { - get - { - this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "event_output_config" - ); - } - init { this._rawData.Set("event_output_config", value); } - } - /// /// The id of the item the price will be associated with. /// @@ -9853,6 +10489,21 @@ 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. /// @@ -9912,12 +10563,12 @@ public double? ConversionRate /// /// The configuration for the rate of the price currency to the invoicing currency. /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? ConversionRateConfig + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? ConversionRateConfig { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( + return this._rawData.GetNullableClass( "conversion_rate_config" ); } @@ -10008,6 +10659,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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,18 +10711,13 @@ public string? ReferenceID public override void Validate() { this.Cadence.Validate(); - this.EventOutputConfig.Validate(); _ = this.ItemID; - if ( - !JsonElement.DeepEquals( - this.ModelType, - JsonSerializer.SerializeToElement("event_output") - ) - ) + 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(); @@ -10070,32 +10729,36 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent() { - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent subscriptionSchedulePlanChangeParamsAddPricePricePercent ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercent) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent( IReadOnlyDictionary rawData ) { this._rawData = new(rawData); - this.ModelType = JsonSerializer.SerializeToElement("event_output"); + this.ModelType = JsonSerializer.SerializeToElement("percent"); } #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePricePercent( FrozenDictionary rawData ) { @@ -10103,8 +10766,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10112,22 +10775,20 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercent FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsAddPricePricePercent.FromRawUnchecked(rawData); } /// /// The cadence to bill for this price on. /// -[JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter) -)] -public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter))] +public enum SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence { Annual, SemiAnnual, @@ -10137,10 +10798,10 @@ public enum SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Custom, } -sealed class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadenceConverter - : JsonConverter +sealed class SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadenceConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10148,23 +10809,21 @@ JsonSerializerOptions options { return JsonSerializer.Deserialize(ref reader, options) switch { - "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual, "semi_annual" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, - "monthly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual, + "monthly" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly, "quarterly" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, - "one_time" => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, - "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, - _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly, + "one_time" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence)(-1), }; } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence value, JsonSerializerOptions options ) { @@ -10172,18 +10831,16 @@ JsonSerializerOptions options writer, value switch { - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual => - "annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Annual => "annual", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.SemiAnnual => "semi_annual", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Monthly => "monthly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Quarterly => "quarterly", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime => + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.OneTime => "one_time", - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom => - "custom", + SubscriptionSchedulePlanChangeParamsAddPricePricePercentCadence.Custom => "custom", _ => throw new OrbInvalidDataException( string.Format("Invalid value '{0}' in {1}", value, nameof(value)) ), @@ -10194,75 +10851,47 @@ JsonSerializerOptions options } /// -/// Configuration for event_output pricing +/// Configuration for percent pricing /// [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig : 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. + /// What percent of the component subtotals to charge /// - public string? GroupingKey + public required double Percent { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("grouping_key"); + return this._rawData.GetNotNullStruct("percent"); } - init { this._rawData.Set("grouping_key", value); } + init { this._rawData.Set("percent", value); } } /// public override void Validate() { - _ = this.UnitRatingKey; - _ = this.DefaultUnitRate; - _ = this.GroupingKey; + _ = this.Percent; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig() { } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig ) - : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } + : base(subscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( IReadOnlyDictionary rawData ) { @@ -10271,7 +10900,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig( FrozenDictionary rawData ) { @@ -10279,8 +10908,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -10288,31 +10917,29 @@ IReadOnlyDictionary rawData } [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( - string unitRatingKey - ) + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig(double percent) : this() { - this.UnitRatingKey = unitRatingKey; + this.Percent = percent; } } -class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfigFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsAddPricePricePercentPercentConfig.FromRawUnchecked( rawData ); } [JsonConverter( - typeof(SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter) + typeof(SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter) )] -public record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig +public record class SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig : ModelBase { public object? Value { get; } = null; @@ -10330,7 +10957,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -10339,7 +10966,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -10348,7 +10975,7 @@ public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( JsonElement element ) { @@ -10359,7 +10986,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 +11007,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +11027,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +11038,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10432,7 +11059,7 @@ public void Switch( break; default: throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } } @@ -10441,7 +11068,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11079,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -10468,16 +11095,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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ), }; } - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( SharedTieredConversionRateConfig value ) => new(value); @@ -10496,18 +11123,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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig" ); } this.Switch((unit) => unit.Validate(), (tiered) => tiered.Validate()); } public virtual bool Equals( - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? 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() { @@ -10515,13 +11142,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 SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig? Read( ref Utf8JsonReader reader, System::Type typeToConvert, JsonSerializerOptions options @@ -10550,12 +11190,10 @@ JsonSerializerOptions 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 +11210,10 @@ JsonSerializerOptions 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 +11222,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig( element ); } @@ -10595,7 +11231,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsAddPricePricePercentConversionRateConfig value, JsonSerializerOptions options ) { @@ -10603,508 +11239,654 @@ 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 + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput : 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, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence + > 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() + /// + /// Configuration for event_output pricing + /// + public required SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig EventOutputConfig { - _ = this.AdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass( + "event_output_config" + ); + } + init { this._rawData.Set("event_output_config", value); } } - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - IReadOnlyDictionary rawData - ) + /// + /// The id of the item the price will be associated with. + /// + public required string ItemID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("item_id"); + } + init { this._rawData.Set("item_id", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsRemoveAdjustment( - 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 SubscriptionSchedulePlanChangeParamsRemoveAdjustment 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 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? 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); -} -[JsonConverter( - typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplaceAdjustment, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw - >) -)] -public sealed record class SubscriptionSchedulePlanChangeParamsReplaceAdjustment : JsonModel -{ /// - /// The definition of a new adjustment to create and add to the subscription. + /// An alias for the price. /// - public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment + public string? ExternalPriceID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass( - "adjustment" - ); + return this._rawData.GetNullableClass("external_price_id"); } - init { this._rawData.Set("adjustment", value); } + init { this._rawData.Set("external_price_id", value); } } /// - /// The id of the adjustment on the plan to replace in the subscription. + /// If the Price represents a fixed cost, this represents the quantity of units applied. /// - public required string ReplacesAdjustmentID + public double? FixedPriceQuantity { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_adjustment_id"); + return this._rawData.GetNullableStruct("fixed_price_quantity"); } - init { this._rawData.Set("replaces_adjustment_id", value); } + init { this._rawData.Set("fixed_price_quantity", value); } } - /// - public override void Validate() + /// + /// The property used to group this price on an invoice + /// + public string? InvoiceGroupingKey { - this.Adjustment.Validate(); - _ = this.ReplacesAdjustmentID; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("invoice_grouping_key"); + } + init { this._rawData.Set("invoice_grouping_key", value); } } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment - ) - : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } - - public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - IReadOnlyDictionary rawData - ) + /// + /// Within 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._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass( + "invoicing_cycle_configuration" + ); + } + init { this._rawData.Set("invoicing_cycle_configuration", value); } } -#pragma warning disable CS8618 - [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplaceAdjustment( - FrozenDictionary rawData - ) + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID { - this._rawData = new(rawData); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } } -#pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( - IReadOnlyDictionary rawData - ) + /// + /// User-specified key/value pairs for the resource. Individual keys can be removed + /// by setting the value to `null`, and the entire metadata mapping can be cleared + /// by setting `metadata` to `null`. + /// + public IReadOnlyDictionary? Metadata { - return new(FrozenDictionary.ToFrozenDictionary(rawData)); + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass>("metadata"); + } + init + { + this._rawData.Set?>( + "metadata", + value == null ? null : FrozenDictionary.ToFrozenDictionary(value) + ); + } } -} -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 + /// + /// A transient ID that can be used to reference this price when adding adjustments + /// in the same API call. + /// + public string? ReferenceID { get { - return this._element ??= JsonSerializer.SerializeToElement( - this.Value, - ModelBase.SerializerOptions - ); + this._rawData.Freeze(); + return this._rawData.GetNullableClass("reference_id"); } + init { this._rawData.Set("reference_id", value); } } - public string? Currency + /// + public override void Validate() { - get + this.Cadence.Validate(); + this.EventOutputConfig.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("event_output") + ) + ) { - return Match( - newPercentageDiscount: (x) => x.Currency, - newUsageDiscount: (x) => x.Currency, - newAmountDiscount: (x) => x.Currency, - newMinimum: (x) => x.Currency, - newMaximum: (x) => x.Currency - ); + throw new OrbInvalidDataException("Invalid value given for constant"); } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; } - public bool? IsInvoiceLevel + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput() { - get - { - return Match( - newPercentageDiscount: (x) => x.IsInvoiceLevel, - newUsageDiscount: (x) => x.IsInvoiceLevel, - newAmountDiscount: (x) => x.IsInvoiceLevel, - newMinimum: (x) => x.IsInvoiceLevel, - newMaximum: (x) => x.IsInvoiceLevel - ); - } + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewPercentageDiscount value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput ) - { - this.Value = value; - this._element = element; - } + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutput) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewUsageDiscount value, - JsonElement? element = null + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + this._rawData = new(rawData); + + this.ModelType = JsonSerializer.SerializeToElement("event_output"); } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewAmountDiscount value, - JsonElement? element = null +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput( + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutput FromRawUnchecked( + IReadOnlyDictionary rawData ) { - this.Value = value; - this._element = element; + return new(FrozenDictionary.ToFrozenDictionary(rawData)); } +} - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value, - JsonElement? element = null +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 ) { - this.Value = value; - this._element = element; + return JsonSerializer.Deserialize(ref reader, options) switch + { + "annual" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Annual, + "semi_annual" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.SemiAnnual, + "monthly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Monthly, + "quarterly" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Quarterly, + "one_time" => + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.OneTime, + "custom" => SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence.Custom, + _ => (SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence)(-1), + }; } - public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputCadence value, + JsonSerializerOptions options + ) { - this._element = element; + 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 + ); } +} +/// +/// Configuration for event_output pricing +/// +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfigFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + : JsonModel +{ /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewPercentageDiscount(out var value)) { - /// // `value` is of type `NewPercentageDiscount` - /// Console.WriteLine(value); - /// } - /// - /// + /// The key in the event data to extract the unit rate from. /// - public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) + public required string UnitRatingKey { - value = this.Value as NewPercentageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_rating_key"); + } + init { this._rawData.Set("unit_rating_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.TryPickNewUsageDiscount(out var value)) { - /// // `value` is of type `NewUsageDiscount` - /// Console.WriteLine(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 bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) + public string? DefaultUnitRate { - value = this.Value as NewUsageDiscount; - return value != null; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("default_unit_rate"); + } + init { this._rawData.Set("default_unit_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.TryPickNewAmountDiscount(out var value)) { - /// // `value` is of type `NewAmountDiscount` - /// Console.WriteLine(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 bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) + public string? GroupingKey { - value = this.Value as NewAmountDiscount; - return value != null; + 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig + ) + : base(subscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputEventOutputConfig( + string unitRatingKey + ) + : this() + { + this.UnitRatingKey = unitRatingKey; + } +} + +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 + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } + + public SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + 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. /// /// @@ -11115,43 +11897,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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + "Data did not match any variant of SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ); } } @@ -11160,7 +11927,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +11938,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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ), }; } - 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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedUnitConversionRateConfig value ) => new(value); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( - NewMaximum value + public static implicit operator SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + SharedTieredConversionRateConfig value ) => new(value); /// @@ -11236,24 +11982,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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig" ); } - 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); - } + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); public override int GetHashCode() { @@ -11261,129 +12001,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 SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfigConverter + : JsonConverter { - public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( + public override SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig? 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 +12081,16 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(element); + return new SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, + SubscriptionSchedulePlanChangeParamsAddPricePriceEventOutputConversionRateConfig value, JsonSerializerOptions options ) { @@ -11407,63 +12098,147 @@ 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< - SubscriptionSchedulePlanChangeParamsReplacePrice, - SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + SubscriptionSchedulePlanChangeParamsRemoveAdjustment, + SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel +public sealed record class SubscriptionSchedulePlanChangeParamsRemoveAdjustment : JsonModel { /// - /// The id of the price on the plan to replace in the subscription. + /// The id of the adjustment to remove on the subscription. /// - public required string ReplacesPriceID + public required string AdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNotNullClass("replaces_price_id"); + return this._rawData.GetNotNullClass("adjustment_id"); } - init { this._rawData.Set("replaces_price_id", value); } + init { this._rawData.Set("adjustment_id", value); } } - /// - /// The definition of a new allocation price to create and add to the subscription. - /// - public NewAllocationPrice? AllocationPrice + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("allocation_price"); - } - init { this._rawData.Set("allocation_price", value); } + _ = this.AdjustmentID; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for - /// the replacement price. - /// - [System::Obsolete("deprecated")] - public IReadOnlyList? Discounts + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + SubscriptionSchedulePlanChangeParamsRemoveAdjustment subscriptionSchedulePlanChangeParamsRemoveAdjustment + ) + : base(subscriptionSchedulePlanChangeParamsRemoveAdjustment) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableStruct>("discounts"); - } - init - { - this._rawData.Set?>( - "discounts", - value == null ? null : ImmutableArray.ToImmutableArray(value) - ); - } + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemoveAdjustment( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } + + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment(string adjustmentID) + : this() + { + this.AdjustmentID = adjustmentID; + } +} + +class SubscriptionSchedulePlanChangeParamsRemoveAdjustmentFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsRemoveAdjustment FromRawUnchecked( + IReadOnlyDictionary rawData + ) => SubscriptionSchedulePlanChangeParamsRemoveAdjustment.FromRawUnchecked(rawData); +} +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsRemovePrice, + SubscriptionSchedulePlanChangeParamsRemovePriceFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsRemovePrice : JsonModel +{ /// - /// The external price id of the price to add to the subscription. + /// The external price id of the price to remove on the subscription. /// public string? ExternalPriceID { @@ -11476,101 +12251,122 @@ public string? ExternalPriceID } /// - /// The new quantity of the price, if the price is a fixed price. + /// The id of the price to remove on the subscription. /// - public double? FixedPriceQuantity + public string? PriceID { get { this._rawData.Freeze(); - return this._rawData.GetNullableStruct("fixed_price_quantity"); + return this._rawData.GetNullableClass("price_id"); } - init { this._rawData.Set("fixed_price_quantity", value); } + init { this._rawData.Set("price_id", value); } } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MaximumAmount + /// + public override void Validate() { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("maximum_amount"); - } - init { this._rawData.Set("maximum_amount", value); } + _ = this.ExternalPriceID; + _ = this.PriceID; } - /// - /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount - /// for the replacement price. - /// - [System::Obsolete("deprecated")] - public string? MinimumAmount + public SubscriptionSchedulePlanChangeParamsRemovePrice() { } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsRemovePrice( + SubscriptionSchedulePlanChangeParamsRemovePrice subscriptionSchedulePlanChangeParamsRemovePrice + ) + : base(subscriptionSchedulePlanChangeParamsRemovePrice) { } +#pragma warning restore CS8618 + + public SubscriptionSchedulePlanChangeParamsRemovePrice( + IReadOnlyDictionary rawData + ) { - get - { - this._rawData.Freeze(); - return this._rawData.GetNullableClass("minimum_amount"); - } - init { this._rawData.Set("minimum_amount", value); } + this._rawData = new(rawData); + } + +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsRemovePrice(FrozenDictionary rawData) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 + + /// + public static SubscriptionSchedulePlanChangeParamsRemovePrice FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + 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 +{ /// - /// New subscription price request body params. + /// The definition of a new adjustment to create and add to the subscription. /// - public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price + public required SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment Adjustment { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass( - "price" + return this._rawData.GetNotNullClass( + "adjustment" ); } - init { this._rawData.Set("price", value); } + init { this._rawData.Set("adjustment", value); } } /// - /// The id of the price to add to the subscription. + /// The id of the adjustment on the plan to replace in the subscription. /// - public string? PriceID + public required string ReplacesAdjustmentID { get { this._rawData.Freeze(); - return this._rawData.GetNullableClass("price_id"); + return this._rawData.GetNotNullClass("replaces_adjustment_id"); } - init { this._rawData.Set("price_id", value); } + init { this._rawData.Set("replaces_adjustment_id", value); } } /// public override void Validate() { - _ = this.ReplacesPriceID; - this.AllocationPrice?.Validate(); - foreach (var item in this.Discounts ?? []) - { - item.Validate(); - } - _ = this.ExternalPriceID; - _ = this.FixedPriceQuantity; - _ = this.MaximumAmount; - _ = this.MinimumAmount; - this.Price?.Validate(); - _ = this.PriceID; + this.Adjustment.Validate(); + _ = this.ReplacesAdjustmentID; } - public SubscriptionSchedulePlanChangeParamsReplacePrice() { } + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment() { } - public SubscriptionSchedulePlanChangeParamsReplacePrice( - SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + SubscriptionSchedulePlanChangeParamsReplaceAdjustment subscriptionSchedulePlanChangeParamsReplaceAdjustment ) - : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } + : base(subscriptionSchedulePlanChangeParamsReplaceAdjustment) { } +#pragma warning restore CS8618 - public SubscriptionSchedulePlanChangeParamsReplacePrice( + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment( IReadOnlyDictionary rawData ) { @@ -11579,42 +12375,37 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) + SubscriptionSchedulePlanChangeParamsReplaceAdjustment( + FrozenDictionary rawData + ) { this._rawData = new(rawData); } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData ) { return new(FrozenDictionary.ToFrozenDictionary(rawData)); } - - [SetsRequiredMembers] - public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) - : this() - { - this.ReplacesPriceID = replacesPriceID; - } } -class SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplaceAdjustment FromRawUnchecked( IReadOnlyDictionary rawData - ) => SubscriptionSchedulePlanChangeParamsReplacePrice.FromRawUnchecked(rawData); + ) => SubscriptionSchedulePlanChangeParamsReplaceAdjustment.FromRawUnchecked(rawData); } /// -/// New subscription price request body params. +/// The definition of a new adjustment to create and add to the subscription. /// -[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter))] -public record class SubscriptionSchedulePlanChangeParamsReplacePricePrice : ModelBase +[JsonConverter(typeof(SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter))] +public record class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment : ModelBase { public object? Value { get; } = null; @@ -11631,1630 +12422,2466 @@ public JsonElement Json } } - public string ItemID + public string? Currency { 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 + return Match( + newPercentageDiscount: (x) => x.Currency, + newUsageDiscount: (x) => x.Currency, + newAmountDiscount: (x) => x.Currency, + newMinimum: (x) => x.Currency, + newMaximum: (x) => x.Currency ); } } - public string Name + public bool? IsInvoiceLevel { 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 + return Match( + newPercentageDiscount: (x) => x.IsInvoiceLevel, + newUsageDiscount: (x) => x.IsInvoiceLevel, + newAmountDiscount: (x) => x.IsInvoiceLevel, + newMinimum: (x) => x.IsInvoiceLevel, + newMaximum: (x) => x.IsInvoiceLevel ); } } - public string? BillableMetricID + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillableMetricID, - newSubscriptionTiered: (x) => x.BillableMetricID, - newSubscriptionBulk: (x) => x.BillableMetricID, - bulkWithFilters: (x) => x.BillableMetricID, - newSubscriptionPackage: (x) => x.BillableMetricID, - newSubscriptionMatrix: (x) => x.BillableMetricID, - newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, - newSubscriptionTieredPackage: (x) => x.BillableMetricID, - newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedTiered: (x) => x.BillableMetricID, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, - newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, - newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, - newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, - tieredWithProration: (x) => x.BillableMetricID, - newSubscriptionUnitWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, - newSubscriptionBulkWithProration: (x) => x.BillableMetricID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, - groupedWithMinMaxThresholds: (x) => x.BillableMetricID, - newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, - newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, - cumulativeGroupedAllocation: (x) => x.BillableMetricID, - minimum: (x) => x.BillableMetricID, - newSubscriptionMinimumComposite: (x) => x.BillableMetricID, - percent: (x) => x.BillableMetricID, - eventOutput: (x) => x.BillableMetricID - ); - } + this.Value = value; + this._element = element; } - public bool? BilledInAdvance - { - 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 - ); - } - } - - public NewBillingCycleConfiguration? BillingCycleConfiguration + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.BillingCycleConfiguration, - newSubscriptionTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionBulk: (x) => x.BillingCycleConfiguration, - bulkWithFilters: (x) => x.BillingCycleConfiguration, - newSubscriptionPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, - tieredWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, - minimum: (x) => x.BillingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, - percent: (x) => x.BillingCycleConfiguration, - eventOutput: (x) => x.BillingCycleConfiguration - ); - } + this.Value = value; + this._element = element; } - public double? ConversionRate + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ConversionRate, - newSubscriptionTiered: (x) => x.ConversionRate, - newSubscriptionBulk: (x) => x.ConversionRate, - bulkWithFilters: (x) => x.ConversionRate, - newSubscriptionPackage: (x) => x.ConversionRate, - newSubscriptionMatrix: (x) => x.ConversionRate, - newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, - newSubscriptionTieredPackage: (x) => x.ConversionRate, - newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedTiered: (x) => x.ConversionRate, - newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, - newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, - newSubscriptionUnitWithPercent: (x) => x.ConversionRate, - newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, - tieredWithProration: (x) => x.ConversionRate, - newSubscriptionUnitWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedAllocation: (x) => x.ConversionRate, - newSubscriptionBulkWithProration: (x) => x.ConversionRate, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, - groupedWithMinMaxThresholds: (x) => x.ConversionRate, - newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, - newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, - newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, - newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, - cumulativeGroupedAllocation: (x) => x.ConversionRate, - minimum: (x) => x.ConversionRate, - newSubscriptionMinimumComposite: (x) => x.ConversionRate, - percent: (x) => x.ConversionRate, - eventOutput: (x) => x.ConversionRate - ); - } + this.Value = value; + this._element = element; } - public string? Currency + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.Currency, - newSubscriptionTiered: (x) => x.Currency, - newSubscriptionBulk: (x) => x.Currency, - bulkWithFilters: (x) => x.Currency, - newSubscriptionPackage: (x) => x.Currency, - newSubscriptionMatrix: (x) => x.Currency, - newSubscriptionThresholdTotalAmount: (x) => x.Currency, - newSubscriptionTieredPackage: (x) => x.Currency, - newSubscriptionTieredWithMinimum: (x) => x.Currency, - newSubscriptionGroupedTiered: (x) => x.Currency, - newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, - newSubscriptionPackageWithAllocation: (x) => x.Currency, - newSubscriptionUnitWithPercent: (x) => x.Currency, - newSubscriptionMatrixWithAllocation: (x) => x.Currency, - tieredWithProration: (x) => x.Currency, - newSubscriptionUnitWithProration: (x) => x.Currency, - newSubscriptionGroupedAllocation: (x) => x.Currency, - newSubscriptionBulkWithProration: (x) => x.Currency, - newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, - groupedWithMinMaxThresholds: (x) => x.Currency, - newSubscriptionMatrixWithDisplayName: (x) => x.Currency, - newSubscriptionGroupedTieredPackage: (x) => x.Currency, - newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, - newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, - cumulativeGroupedAllocation: (x) => x.Currency, - minimum: (x) => x.Currency, - newSubscriptionMinimumComposite: (x) => x.Currency, - percent: (x) => x.Currency, - eventOutput: (x) => x.Currency - ); - } + this.Value = value; + this._element = element; } - public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value, + JsonElement? element = null + ) { - get - { - return Match( - newSubscriptionUnit: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulk: (x) => x.DimensionalPriceConfiguration, - bulkWithFilters: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrix: (x) => x.DimensionalPriceConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTiered: (x) => x.DimensionalPriceConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithPercent: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.DimensionalPriceConfiguration, - tieredWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionUnitWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - newSubscriptionBulkWithProration: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.DimensionalPriceConfiguration, - groupedWithMinMaxThresholds: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.DimensionalPriceConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.DimensionalPriceConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.DimensionalPriceConfiguration, - cumulativeGroupedAllocation: (x) => x.DimensionalPriceConfiguration, - minimum: (x) => x.DimensionalPriceConfiguration, - newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, - percent: (x) => x.DimensionalPriceConfiguration, - eventOutput: (x) => x.DimensionalPriceConfiguration - ); - } + this.Value = value; + this._element = element; } - public string? ExternalPriceID + public SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment(JsonElement element) { - 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._element = element; } - public double? FixedPriceQuantity - { - get - { - return Match( - newSubscriptionUnit: (x) => x.FixedPriceQuantity, - newSubscriptionTiered: (x) => x.FixedPriceQuantity, - newSubscriptionBulk: (x) => x.FixedPriceQuantity, - bulkWithFilters: (x) => x.FixedPriceQuantity, - newSubscriptionPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMatrix: (x) => x.FixedPriceQuantity, - newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, - newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, - tieredWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, - newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, - groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, - newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, - newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, - newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, - cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, - minimum: (x) => x.FixedPriceQuantity, - newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, - percent: (x) => x.FixedPriceQuantity, - eventOutput: (x) => x.FixedPriceQuantity - ); - } - } - - public string? InvoiceGroupingKey - { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoiceGroupingKey, - newSubscriptionTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionBulk: (x) => x.InvoiceGroupingKey, - bulkWithFilters: (x) => x.InvoiceGroupingKey, - newSubscriptionPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, - newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, - tieredWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, - newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, - groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, - newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, - cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, - minimum: (x) => x.InvoiceGroupingKey, - newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, - percent: (x) => x.InvoiceGroupingKey, - eventOutput: (x) => x.InvoiceGroupingKey - ); - } - } - - public NewBillingCycleConfiguration? InvoicingCycleConfiguration + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewPercentageDiscount(out var value)) { + /// // `value` is of type `NewPercentageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewPercentageDiscount([NotNullWhen(true)] out NewPercentageDiscount? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulk: (x) => x.InvoicingCycleConfiguration, - bulkWithFilters: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrix: (x) => x.InvoicingCycleConfiguration, - newSubscriptionThresholdTotalAmount: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTiered: (x) => x.InvoicingCycleConfiguration, - newSubscriptionTieredPackageWithMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionPackageWithAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithPercent: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithAllocation: (x) => x.InvoicingCycleConfiguration, - tieredWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionUnitWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - newSubscriptionBulkWithProration: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoicingCycleConfiguration, - groupedWithMinMaxThresholds: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMatrixWithDisplayName: (x) => x.InvoicingCycleConfiguration, - newSubscriptionGroupedTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMaxGroupTieredPackage: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoicingCycleConfiguration, - newSubscriptionScalableMatrixWithTieredPricing: (x) => - x.InvoicingCycleConfiguration, - newSubscriptionCumulativeGroupedBulk: (x) => x.InvoicingCycleConfiguration, - cumulativeGroupedAllocation: (x) => x.InvoicingCycleConfiguration, - minimum: (x) => x.InvoicingCycleConfiguration, - newSubscriptionMinimumComposite: (x) => x.InvoicingCycleConfiguration, - percent: (x) => x.InvoicingCycleConfiguration, - eventOutput: (x) => x.InvoicingCycleConfiguration - ); - } + value = this.Value as NewPercentageDiscount; + return value != null; } - public string? ReferenceID + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewUsageDiscount(out var value)) { + /// // `value` is of type `NewUsageDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewUsageDiscount([NotNullWhen(true)] out NewUsageDiscount? value) { - get - { - return Match( - newSubscriptionUnit: (x) => x.ReferenceID, - newSubscriptionTiered: (x) => x.ReferenceID, - newSubscriptionBulk: (x) => x.ReferenceID, - bulkWithFilters: (x) => x.ReferenceID, - newSubscriptionPackage: (x) => x.ReferenceID, - newSubscriptionMatrix: (x) => x.ReferenceID, - newSubscriptionThresholdTotalAmount: (x) => x.ReferenceID, - newSubscriptionTieredPackage: (x) => x.ReferenceID, - newSubscriptionTieredWithMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedTiered: (x) => x.ReferenceID, - newSubscriptionTieredPackageWithMinimum: (x) => x.ReferenceID, - newSubscriptionPackageWithAllocation: (x) => x.ReferenceID, - newSubscriptionUnitWithPercent: (x) => x.ReferenceID, - newSubscriptionMatrixWithAllocation: (x) => x.ReferenceID, - tieredWithProration: (x) => x.ReferenceID, - newSubscriptionUnitWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedAllocation: (x) => x.ReferenceID, - newSubscriptionBulkWithProration: (x) => x.ReferenceID, - newSubscriptionGroupedWithProratedMinimum: (x) => x.ReferenceID, - newSubscriptionGroupedWithMeteredMinimum: (x) => x.ReferenceID, - groupedWithMinMaxThresholds: (x) => x.ReferenceID, - newSubscriptionMatrixWithDisplayName: (x) => x.ReferenceID, - newSubscriptionGroupedTieredPackage: (x) => x.ReferenceID, - newSubscriptionMaxGroupTieredPackage: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ReferenceID, - newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ReferenceID, - newSubscriptionCumulativeGroupedBulk: (x) => x.ReferenceID, - cumulativeGroupedAllocation: (x) => x.ReferenceID, - minimum: (x) => x.ReferenceID, - newSubscriptionMinimumComposite: (x) => x.ReferenceID, - percent: (x) => x.ReferenceID, - eventOutput: (x) => x.ReferenceID - ); - } + value = this.Value as NewUsageDiscount; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitPrice value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewAmountDiscount(out var value)) { + /// // `value` is of type `NewAmountDiscount` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewAmountDiscount([NotNullWhen(true)] out NewAmountDiscount? value) { - this.Value = value; - this._element = element; + value = this.Value as NewAmountDiscount; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPrice value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMinimum(out var value)) { + /// // `value` is of type `NewMinimum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMinimum([NotNullWhen(true)] out NewMinimum? value) { - this.Value = value; - this._element = element; + value = this.Value as NewMinimum; + return value != null; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkPrice value, - JsonElement? element = null - ) + /// + /// Returns true and sets the out parameter if the instance was constructed with a variant of + /// type . + /// + /// Consider using or if you need to handle every variant. + /// + /// + /// + /// if (instance.TryPickNewMaximum(out var value)) { + /// // `value` is of type `NewMaximum` + /// Console.WriteLine(value); + /// } + /// + /// + /// + public bool TryPickNewMaximum([NotNullWhen(true)] out NewMaximum? value) { - this.Value = value; - this._element = element; + value = this.Value as NewMaximum; + return value != null; } - 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 + /// + /// Calls the function parameter corresponding to the variant the instance was constructed with. + /// + /// Use the TryPick method(s) if you don't need to handle every variant, or + /// if you need your function parameters to return something. + /// + /// + /// Thrown when the 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 ) { - this.Value = value; - this._element = element; + 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" + ); + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - 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( + /// (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 ) { - this.Value = value; - this._element = element; + 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" + ), + }; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewPercentageDiscount value + ) => new(value); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewUsageDiscount value + ) => new(value); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewAmountDiscount value + ) => new(value); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMinimum value + ) => new(value); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public static implicit operator SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment( + NewMaximum value + ) => new(value); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice 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 SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment" + ); + } + this.Switch( + (newPercentageDiscount) => newPercentageDiscount.Validate(), + (newUsageDiscount) => newUsageDiscount.Validate(), + (newAmountDiscount) => newAmountDiscount.Validate(), + (newMinimum) => newMinimum.Validate(), + (newMaximum) => newMaximum.Validate() + ); } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public virtual bool Equals( + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? other + ) => + other != null + && this.VariantIndex() == other.VariantIndex() + && JsonElement.DeepEquals(this.Json, other.Json); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value, - JsonElement? element = null - ) + public override int GetHashCode() { - this.Value = value; - this._element = element; + return 0; } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + public override string ToString() => + JsonSerializer.Serialize( + FriendlyJsonPrinter.PrintValue(this.Json), + ModelBase.ToStringSerializerOptions + ); - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value, - JsonElement? element = null - ) + int VariantIndex() { - this.Value = value; - this._element = element; + return this.Value switch + { + NewPercentageDiscount _ => 0, + NewUsageDiscount _ => 1, + NewAmountDiscount _ => 2, + NewMinimum _ => 3, + NewMaximum _ => 4, + _ => -1, + }; } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value, - JsonElement? element = null +sealed class SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustmentConverter + : JsonConverter +{ + public override SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment? Read( + ref Utf8JsonReader reader, + System::Type typeToConvert, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; - } + var element = JsonSerializer.Deserialize(ref reader, options); + string? adjustmentType; + try + { + adjustmentType = element.GetProperty("adjustment_type").GetString(); + } + catch + { + adjustmentType = null; + } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + switch (adjustmentType) + { + case "percentage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; - } + return new(element); + } + case "usage_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + return new(deserialized, element); + } + } + catch (JsonException) + { + // ignore + } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value, - JsonElement? element = null - ) - { - this.Value = value; - this._element = element; + return new(element); + } + case "amount_discount": + { + try + { + var deserialized = JsonSerializer.Deserialize( + element, + options + ); + if (deserialized != null) + { + 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); + } + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value, - JsonElement? element = null + public override void Write( + Utf8JsonWriter writer, + SubscriptionSchedulePlanChangeParamsReplaceAdjustmentAdjustment value, + JsonSerializerOptions options ) { - this.Value = value; - this._element = element; + JsonSerializer.Serialize(writer, value.Json, options); } +} - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value, - JsonElement? element = null - ) +[JsonConverter( + typeof(JsonModelConverter< + SubscriptionSchedulePlanChangeParamsReplacePrice, + SubscriptionSchedulePlanChangeParamsReplacePriceFromRaw + >) +)] +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePrice : JsonModel +{ + /// + /// The id of the price on the plan to replace in the subscription. + /// + public required string ReplacesPriceID { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("replaces_price_id"); + } + init { this._rawData.Set("replaces_price_id", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value, - JsonElement? element = null - ) + /// + /// The definition of a new allocation price to create and add to the subscription. + /// + public NewAllocationPrice? AllocationPrice { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("allocation_price"); + } + init { this._rawData.Set("allocation_price", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value, - JsonElement? element = null - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's discounts for + /// the replacement price. + /// + [System::Obsolete("deprecated")] + public IReadOnlyList? Discounts { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableStruct>("discounts"); + } + init + { + this._rawData.Set?>( + "discounts", + value == null ? null : ImmutableArray.ToImmutableArray(value) + ); + } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value, - JsonElement? element = null - ) + /// + /// The external price id of the price to add to 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value, - JsonElement? element = null - ) + /// + /// The new quantity of the price, if the price is a fixed price. + /// + 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value, - JsonElement? element = null - ) + /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's maximum amount + /// for the replacement price. + /// + [System::Obsolete("deprecated")] + public string? MaximumAmount { - this.Value = value; - this._element = element; + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("maximum_amount"); + } + init { this._rawData.Set("maximum_amount", value); } } - public SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value, - JsonElement? element = null - ) + /// + /// Override values for parameterized billable metric variables. Keys are parameter + /// names, values are the override values. + /// + public IReadOnlyDictionary? MetricParameterOverrides { - 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; + 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.TryPickNewSubscriptionUnit(out var value)) { - /// // `value` is of type `NewSubscriptionUnitPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// [DEPRECATED] Use add_adjustments instead. The subscription's minimum amount + /// for the replacement price. /// - public bool TryPickNewSubscriptionUnit([NotNullWhen(true)] out NewSubscriptionUnitPrice? value) + [System::Obsolete("deprecated")] + public string? MinimumAmount { - value = this.Value as NewSubscriptionUnitPrice; - 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.TryPickNewSubscriptionTiered(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// New subscription price request body params. /// - public bool TryPickNewSubscriptionTiered( - [NotNullWhen(true)] out NewSubscriptionTieredPrice? value - ) + public SubscriptionSchedulePlanChangeParamsReplacePricePrice? Price { - value = this.Value as NewSubscriptionTieredPrice; - 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.TryPickNewSubscriptionBulk(out var value)) { - /// // `value` is of type `NewSubscriptionBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// + /// The id of the price to add to the subscription. /// - public bool TryPickNewSubscriptionBulk([NotNullWhen(true)] out NewSubscriptionBulkPrice? value) + public string? PriceID { - value = this.Value as NewSubscriptionBulkPrice; - 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.TryPickBulkWithFilters(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickBulkWithFilters( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters? value - ) + /// + public override void Validate() { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters; - 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.TryPickNewSubscriptionPackage(out var value)) { - /// // `value` is of type `NewSubscriptionPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackage( - [NotNullWhen(true)] out NewSubscriptionPackagePrice? value - ) - { - value = this.Value as NewSubscriptionPackagePrice; - return value != null; - } + public SubscriptionSchedulePlanChangeParamsReplacePrice() { } - /// - /// Returns true and sets the 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 +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice( + SubscriptionSchedulePlanChangeParamsReplacePrice subscriptionSchedulePlanChangeParamsReplacePrice ) - { - value = this.Value as NewSubscriptionMatrixPrice; - return value != null; - } + : base(subscriptionSchedulePlanChangeParamsReplacePrice) { } +#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.TryPickNewSubscriptionThresholdTotalAmount(out var value)) { - /// // `value` is of type `NewSubscriptionThresholdTotalAmountPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionThresholdTotalAmount( - [NotNullWhen(true)] out NewSubscriptionThresholdTotalAmountPrice? value + public SubscriptionSchedulePlanChangeParamsReplacePrice( + IReadOnlyDictionary rawData ) { - value = this.Value as NewSubscriptionThresholdTotalAmountPrice; - 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.TryPickNewSubscriptionTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackage( - [NotNullWhen(true)] out NewSubscriptionTieredPackagePrice? value - ) +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePrice(FrozenDictionary rawData) { - value = this.Value as NewSubscriptionTieredPackagePrice; - 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.TryPickNewSubscriptionTieredWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredWithMinimumPrice? value + /// + public static SubscriptionSchedulePlanChangeParamsReplacePrice FromRawUnchecked( + IReadOnlyDictionary rawData ) { - value = this.Value as NewSubscriptionTieredWithMinimumPrice; - 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.TryPickNewSubscriptionGroupedTiered(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTiered( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPrice? value - ) + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePrice(string replacesPriceID) + : this() { - value = this.Value as NewSubscriptionGroupedTieredPrice; - 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.TryPickNewSubscriptionTieredPackageWithMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionTieredPackageWithMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionTieredPackageWithMinimum( - [NotNullWhen(true)] out NewSubscriptionTieredPackageWithMinimumPrice? 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 { - value = this.Value as NewSubscriptionTieredPackageWithMinimumPrice; - 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.TryPickNewSubscriptionPackageWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionPackageWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionPackageWithAllocation( - [NotNullWhen(true)] out NewSubscriptionPackageWithAllocationPrice? value - ) + public string ItemID { - value = this.Value as NewSubscriptionPackageWithAllocationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ItemID, + newSubscriptionTiered: (x) => x.ItemID, + newSubscriptionBulk: (x) => x.ItemID, + bulkWithFilters: (x) => x.ItemID, + newSubscriptionPackage: (x) => x.ItemID, + newSubscriptionMatrix: (x) => x.ItemID, + newSubscriptionThresholdTotalAmount: (x) => x.ItemID, + newSubscriptionTieredPackage: (x) => x.ItemID, + newSubscriptionTieredWithMinimum: (x) => x.ItemID, + newSubscriptionGroupedTiered: (x) => x.ItemID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ItemID, + newSubscriptionPackageWithAllocation: (x) => x.ItemID, + newSubscriptionUnitWithPercent: (x) => x.ItemID, + newSubscriptionMatrixWithAllocation: (x) => x.ItemID, + tieredWithProration: (x) => x.ItemID, + newSubscriptionUnitWithProration: (x) => x.ItemID, + newSubscriptionGroupedAllocation: (x) => x.ItemID, + newSubscriptionBulkWithProration: (x) => x.ItemID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ItemID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ItemID, + groupedWithMinMaxThresholds: (x) => x.ItemID, + newSubscriptionMatrixWithDisplayName: (x) => x.ItemID, + newSubscriptionGroupedTieredPackage: (x) => x.ItemID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ItemID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ItemID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ItemID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ItemID, + cumulativeGroupedAllocation: (x) => x.ItemID, + dailyCreditAllowance: (x) => x.ItemID, + meteredAllowance: (x) => x.ItemID, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionUnitWithPercent(out var value)) { - /// // `value` is of type `NewSubscriptionUnitWithPercentPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionUnitWithPercent( - [NotNullWhen(true)] out NewSubscriptionUnitWithPercentPrice? value - ) + public string Name { - value = this.Value as NewSubscriptionUnitWithPercentPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.Name, + newSubscriptionTiered: (x) => x.Name, + newSubscriptionBulk: (x) => x.Name, + bulkWithFilters: (x) => x.Name, + newSubscriptionPackage: (x) => x.Name, + newSubscriptionMatrix: (x) => x.Name, + newSubscriptionThresholdTotalAmount: (x) => x.Name, + newSubscriptionTieredPackage: (x) => x.Name, + newSubscriptionTieredWithMinimum: (x) => x.Name, + newSubscriptionGroupedTiered: (x) => x.Name, + newSubscriptionTieredPackageWithMinimum: (x) => x.Name, + newSubscriptionPackageWithAllocation: (x) => x.Name, + newSubscriptionUnitWithPercent: (x) => x.Name, + newSubscriptionMatrixWithAllocation: (x) => x.Name, + tieredWithProration: (x) => x.Name, + newSubscriptionUnitWithProration: (x) => x.Name, + newSubscriptionGroupedAllocation: (x) => x.Name, + newSubscriptionBulkWithProration: (x) => x.Name, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Name, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Name, + groupedWithMinMaxThresholds: (x) => x.Name, + newSubscriptionMatrixWithDisplayName: (x) => x.Name, + newSubscriptionGroupedTieredPackage: (x) => x.Name, + newSubscriptionMaxGroupTieredPackage: (x) => x.Name, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Name, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Name, + newSubscriptionCumulativeGroupedBulk: (x) => x.Name, + cumulativeGroupedAllocation: (x) => x.Name, + dailyCreditAllowance: (x) => x.Name, + meteredAllowance: (x) => x.Name, + newSubscriptionMinimumComposite: (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.TryPickNewSubscriptionMatrixWithAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithAllocation( - [NotNullWhen(true)] out NewSubscriptionMatrixWithAllocationPrice? value - ) + public string? BillableMetricID { - value = this.Value as NewSubscriptionMatrixWithAllocationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillableMetricID, + newSubscriptionTiered: (x) => x.BillableMetricID, + newSubscriptionBulk: (x) => x.BillableMetricID, + bulkWithFilters: (x) => x.BillableMetricID, + newSubscriptionPackage: (x) => x.BillableMetricID, + newSubscriptionMatrix: (x) => x.BillableMetricID, + newSubscriptionThresholdTotalAmount: (x) => x.BillableMetricID, + newSubscriptionTieredPackage: (x) => x.BillableMetricID, + newSubscriptionTieredWithMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedTiered: (x) => x.BillableMetricID, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillableMetricID, + newSubscriptionPackageWithAllocation: (x) => x.BillableMetricID, + newSubscriptionUnitWithPercent: (x) => x.BillableMetricID, + newSubscriptionMatrixWithAllocation: (x) => x.BillableMetricID, + tieredWithProration: (x) => x.BillableMetricID, + newSubscriptionUnitWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedAllocation: (x) => x.BillableMetricID, + newSubscriptionBulkWithProration: (x) => x.BillableMetricID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillableMetricID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillableMetricID, + groupedWithMinMaxThresholds: (x) => x.BillableMetricID, + newSubscriptionMatrixWithDisplayName: (x) => x.BillableMetricID, + newSubscriptionGroupedTieredPackage: (x) => x.BillableMetricID, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillableMetricID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillableMetricID, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillableMetricID, + cumulativeGroupedAllocation: (x) => x.BillableMetricID, + dailyCreditAllowance: (x) => x.BillableMetricID, + meteredAllowance: (x) => x.BillableMetricID, + newSubscriptionMinimumComposite: (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.TryPickTieredWithProration(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickTieredWithProration( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration? value - ) + public bool? BilledInAdvance { - 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; + 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, + dailyCreditAllowance: (x) => x.BilledInAdvance, + meteredAllowance: (x) => x.BilledInAdvance, + newSubscriptionMinimumComposite: (x) => x.BilledInAdvance, + percent: (x) => x.BilledInAdvance, + eventOutput: (x) => x.BilledInAdvance + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedAllocation(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedAllocationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedAllocation( - [NotNullWhen(true)] out NewSubscriptionGroupedAllocationPrice? value - ) + public NewBillingCycleConfiguration? BillingCycleConfiguration { - value = this.Value as NewSubscriptionGroupedAllocationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.BillingCycleConfiguration, + newSubscriptionTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionBulk: (x) => x.BillingCycleConfiguration, + bulkWithFilters: (x) => x.BillingCycleConfiguration, + newSubscriptionPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrix: (x) => x.BillingCycleConfiguration, + newSubscriptionThresholdTotalAmount: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTiered: (x) => x.BillingCycleConfiguration, + newSubscriptionTieredPackageWithMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionPackageWithAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithPercent: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithAllocation: (x) => x.BillingCycleConfiguration, + tieredWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionUnitWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedAllocation: (x) => x.BillingCycleConfiguration, + newSubscriptionBulkWithProration: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithProratedMinimum: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.BillingCycleConfiguration, + groupedWithMinMaxThresholds: (x) => x.BillingCycleConfiguration, + newSubscriptionMatrixWithDisplayName: (x) => x.BillingCycleConfiguration, + newSubscriptionGroupedTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionMaxGroupTieredPackage: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.BillingCycleConfiguration, + newSubscriptionCumulativeGroupedBulk: (x) => x.BillingCycleConfiguration, + cumulativeGroupedAllocation: (x) => x.BillingCycleConfiguration, + dailyCreditAllowance: (x) => x.BillingCycleConfiguration, + meteredAllowance: (x) => x.BillingCycleConfiguration, + newSubscriptionMinimumComposite: (x) => x.BillingCycleConfiguration, + percent: (x) => x.BillingCycleConfiguration, + eventOutput: (x) => x.BillingCycleConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionBulkWithProration(out var value)) { - /// // `value` is of type `NewSubscriptionBulkWithProrationPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionBulkWithProration( - [NotNullWhen(true)] out NewSubscriptionBulkWithProrationPrice? value - ) + public double? ConversionRate { - value = this.Value as NewSubscriptionBulkWithProrationPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ConversionRate, + newSubscriptionTiered: (x) => x.ConversionRate, + newSubscriptionBulk: (x) => x.ConversionRate, + bulkWithFilters: (x) => x.ConversionRate, + newSubscriptionPackage: (x) => x.ConversionRate, + newSubscriptionMatrix: (x) => x.ConversionRate, + newSubscriptionThresholdTotalAmount: (x) => x.ConversionRate, + newSubscriptionTieredPackage: (x) => x.ConversionRate, + newSubscriptionTieredWithMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedTiered: (x) => x.ConversionRate, + newSubscriptionTieredPackageWithMinimum: (x) => x.ConversionRate, + newSubscriptionPackageWithAllocation: (x) => x.ConversionRate, + newSubscriptionUnitWithPercent: (x) => x.ConversionRate, + newSubscriptionMatrixWithAllocation: (x) => x.ConversionRate, + tieredWithProration: (x) => x.ConversionRate, + newSubscriptionUnitWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedAllocation: (x) => x.ConversionRate, + newSubscriptionBulkWithProration: (x) => x.ConversionRate, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ConversionRate, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ConversionRate, + groupedWithMinMaxThresholds: (x) => x.ConversionRate, + newSubscriptionMatrixWithDisplayName: (x) => x.ConversionRate, + newSubscriptionGroupedTieredPackage: (x) => x.ConversionRate, + newSubscriptionMaxGroupTieredPackage: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ConversionRate, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ConversionRate, + newSubscriptionCumulativeGroupedBulk: (x) => x.ConversionRate, + cumulativeGroupedAllocation: (x) => x.ConversionRate, + dailyCreditAllowance: (x) => x.ConversionRate, + meteredAllowance: (x) => x.ConversionRate, + newSubscriptionMinimumComposite: (x) => x.ConversionRate, + percent: (x) => x.ConversionRate, + eventOutput: (x) => x.ConversionRate + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithProratedMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithProratedMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithProratedMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithProratedMinimumPrice? value - ) + public string? Currency { - value = this.Value as NewSubscriptionGroupedWithProratedMinimumPrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.Currency, + newSubscriptionTiered: (x) => x.Currency, + newSubscriptionBulk: (x) => x.Currency, + bulkWithFilters: (x) => x.Currency, + newSubscriptionPackage: (x) => x.Currency, + newSubscriptionMatrix: (x) => x.Currency, + newSubscriptionThresholdTotalAmount: (x) => x.Currency, + newSubscriptionTieredPackage: (x) => x.Currency, + newSubscriptionTieredWithMinimum: (x) => x.Currency, + newSubscriptionGroupedTiered: (x) => x.Currency, + newSubscriptionTieredPackageWithMinimum: (x) => x.Currency, + newSubscriptionPackageWithAllocation: (x) => x.Currency, + newSubscriptionUnitWithPercent: (x) => x.Currency, + newSubscriptionMatrixWithAllocation: (x) => x.Currency, + tieredWithProration: (x) => x.Currency, + newSubscriptionUnitWithProration: (x) => x.Currency, + newSubscriptionGroupedAllocation: (x) => x.Currency, + newSubscriptionBulkWithProration: (x) => x.Currency, + newSubscriptionGroupedWithProratedMinimum: (x) => x.Currency, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.Currency, + groupedWithMinMaxThresholds: (x) => x.Currency, + newSubscriptionMatrixWithDisplayName: (x) => x.Currency, + newSubscriptionGroupedTieredPackage: (x) => x.Currency, + newSubscriptionMaxGroupTieredPackage: (x) => x.Currency, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.Currency, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.Currency, + newSubscriptionCumulativeGroupedBulk: (x) => x.Currency, + cumulativeGroupedAllocation: (x) => x.Currency, + dailyCreditAllowance: (x) => x.Currency, + meteredAllowance: (x) => x.Currency, + newSubscriptionMinimumComposite: (x) => x.Currency, + percent: (x) => x.Currency, + eventOutput: (x) => x.Currency + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedWithMeteredMinimum(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedWithMeteredMinimumPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedWithMeteredMinimum( - [NotNullWhen(true)] out NewSubscriptionGroupedWithMeteredMinimumPrice? value - ) + public NewDimensionalPriceConfiguration? DimensionalPriceConfiguration { - 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; + 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, + dailyCreditAllowance: (x) => x.DimensionalPriceConfiguration, + meteredAllowance: (x) => x.DimensionalPriceConfiguration, + newSubscriptionMinimumComposite: (x) => x.DimensionalPriceConfiguration, + percent: (x) => x.DimensionalPriceConfiguration, + eventOutput: (x) => x.DimensionalPriceConfiguration + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMatrixWithDisplayName(out var value)) { - /// // `value` is of type `NewSubscriptionMatrixWithDisplayNamePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMatrixWithDisplayName( - [NotNullWhen(true)] out NewSubscriptionMatrixWithDisplayNamePrice? value - ) + public string? ExternalPriceID { - value = this.Value as NewSubscriptionMatrixWithDisplayNamePrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.ExternalPriceID, + newSubscriptionTiered: (x) => x.ExternalPriceID, + newSubscriptionBulk: (x) => x.ExternalPriceID, + bulkWithFilters: (x) => x.ExternalPriceID, + newSubscriptionPackage: (x) => x.ExternalPriceID, + newSubscriptionMatrix: (x) => x.ExternalPriceID, + newSubscriptionThresholdTotalAmount: (x) => x.ExternalPriceID, + newSubscriptionTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionTieredWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedTiered: (x) => x.ExternalPriceID, + newSubscriptionTieredPackageWithMinimum: (x) => x.ExternalPriceID, + newSubscriptionPackageWithAllocation: (x) => x.ExternalPriceID, + newSubscriptionUnitWithPercent: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithAllocation: (x) => x.ExternalPriceID, + tieredWithProration: (x) => x.ExternalPriceID, + newSubscriptionUnitWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedAllocation: (x) => x.ExternalPriceID, + newSubscriptionBulkWithProration: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithProratedMinimum: (x) => x.ExternalPriceID, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.ExternalPriceID, + groupedWithMinMaxThresholds: (x) => x.ExternalPriceID, + newSubscriptionMatrixWithDisplayName: (x) => x.ExternalPriceID, + newSubscriptionGroupedTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionMaxGroupTieredPackage: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.ExternalPriceID, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.ExternalPriceID, + newSubscriptionCumulativeGroupedBulk: (x) => x.ExternalPriceID, + cumulativeGroupedAllocation: (x) => x.ExternalPriceID, + dailyCreditAllowance: (x) => x.ExternalPriceID, + meteredAllowance: (x) => x.ExternalPriceID, + newSubscriptionMinimumComposite: (x) => x.ExternalPriceID, + percent: (x) => x.ExternalPriceID, + eventOutput: (x) => x.ExternalPriceID + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionGroupedTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionGroupedTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionGroupedTieredPackage( - [NotNullWhen(true)] out NewSubscriptionGroupedTieredPackagePrice? value - ) + public double? FixedPriceQuantity { - value = this.Value as NewSubscriptionGroupedTieredPackagePrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.FixedPriceQuantity, + newSubscriptionTiered: (x) => x.FixedPriceQuantity, + newSubscriptionBulk: (x) => x.FixedPriceQuantity, + bulkWithFilters: (x) => x.FixedPriceQuantity, + newSubscriptionPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMatrix: (x) => x.FixedPriceQuantity, + newSubscriptionThresholdTotalAmount: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionTieredWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTiered: (x) => x.FixedPriceQuantity, + newSubscriptionTieredPackageWithMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionPackageWithAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithPercent: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithAllocation: (x) => x.FixedPriceQuantity, + tieredWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionUnitWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedAllocation: (x) => x.FixedPriceQuantity, + newSubscriptionBulkWithProration: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithProratedMinimum: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.FixedPriceQuantity, + groupedWithMinMaxThresholds: (x) => x.FixedPriceQuantity, + newSubscriptionMatrixWithDisplayName: (x) => x.FixedPriceQuantity, + newSubscriptionGroupedTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionMaxGroupTieredPackage: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.FixedPriceQuantity, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.FixedPriceQuantity, + newSubscriptionCumulativeGroupedBulk: (x) => x.FixedPriceQuantity, + cumulativeGroupedAllocation: (x) => x.FixedPriceQuantity, + dailyCreditAllowance: (x) => x.FixedPriceQuantity, + meteredAllowance: (x) => x.FixedPriceQuantity, + newSubscriptionMinimumComposite: (x) => x.FixedPriceQuantity, + percent: (x) => x.FixedPriceQuantity, + eventOutput: (x) => x.FixedPriceQuantity + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionMaxGroupTieredPackage(out var value)) { - /// // `value` is of type `NewSubscriptionMaxGroupTieredPackagePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMaxGroupTieredPackage( - [NotNullWhen(true)] out NewSubscriptionMaxGroupTieredPackagePrice? value - ) + public string? InvoiceGroupingKey { - value = this.Value as NewSubscriptionMaxGroupTieredPackagePrice; - return value != null; + get + { + return Match( + newSubscriptionUnit: (x) => x.InvoiceGroupingKey, + newSubscriptionTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionBulk: (x) => x.InvoiceGroupingKey, + bulkWithFilters: (x) => x.InvoiceGroupingKey, + newSubscriptionPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrix: (x) => x.InvoiceGroupingKey, + newSubscriptionThresholdTotalAmount: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTiered: (x) => x.InvoiceGroupingKey, + newSubscriptionTieredPackageWithMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionPackageWithAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithPercent: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithAllocation: (x) => x.InvoiceGroupingKey, + tieredWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionUnitWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedAllocation: (x) => x.InvoiceGroupingKey, + newSubscriptionBulkWithProration: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithProratedMinimum: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedWithMeteredMinimum: (x) => x.InvoiceGroupingKey, + groupedWithMinMaxThresholds: (x) => x.InvoiceGroupingKey, + newSubscriptionMatrixWithDisplayName: (x) => x.InvoiceGroupingKey, + newSubscriptionGroupedTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionMaxGroupTieredPackage: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithUnitPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionScalableMatrixWithTieredPricing: (x) => x.InvoiceGroupingKey, + newSubscriptionCumulativeGroupedBulk: (x) => x.InvoiceGroupingKey, + cumulativeGroupedAllocation: (x) => x.InvoiceGroupingKey, + dailyCreditAllowance: (x) => x.InvoiceGroupingKey, + meteredAllowance: (x) => x.InvoiceGroupingKey, + newSubscriptionMinimumComposite: (x) => x.InvoiceGroupingKey, + percent: (x) => x.InvoiceGroupingKey, + eventOutput: (x) => x.InvoiceGroupingKey + ); + } } - /// - /// Returns true and sets the out parameter if the instance was constructed with a variant of - /// type . - /// - /// Consider using or if you need to handle every variant. - /// - /// - /// - /// if (instance.TryPickNewSubscriptionScalableMatrixWithUnitPricing(out var value)) { - /// // `value` is of type `NewSubscriptionScalableMatrixWithUnitPricingPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionScalableMatrixWithUnitPricing( - [NotNullWhen(true)] out NewSubscriptionScalableMatrixWithUnitPricingPrice? value - ) + public NewBillingCycleConfiguration? InvoicingCycleConfiguration { - 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 + 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, + 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, + 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, + 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 ) { - value = this.Value as NewSubscriptionScalableMatrixWithTieredPricingPrice; - 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.TryPickNewSubscriptionCumulativeGroupedBulk(out var value)) { - /// // `value` is of type `NewSubscriptionCumulativeGroupedBulkPrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionCumulativeGroupedBulk( - [NotNullWhen(true)] out NewSubscriptionCumulativeGroupedBulkPrice? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionTieredPrice value, + JsonElement? element = null ) { - value = this.Value as NewSubscriptionCumulativeGroupedBulkPrice; - 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.TryPickCumulativeGroupedAllocation(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickCumulativeGroupedAllocation( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionBulkPrice value, + JsonElement? element = null ) { - value = - this.Value - as SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation; - 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.TryPickMinimum(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickMinimum( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value, + JsonElement? element = null ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum; - 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.TryPickNewSubscriptionMinimumComposite(out var value)) { - /// // `value` is of type `NewSubscriptionMinimumCompositePrice` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickNewSubscriptionMinimumComposite( - [NotNullWhen(true)] out NewSubscriptionMinimumCompositePrice? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionPackagePrice value, + JsonElement? element = null ) { - value = this.Value as NewSubscriptionMinimumCompositePrice; - 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.TryPickPercent(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePricePercent` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickPercent( - [NotNullWhen(true)] out SubscriptionSchedulePlanChangeParamsReplacePricePricePercent? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionMatrixPrice value, + JsonElement? element = null ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePricePercent; - 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.TryPickEventOutput(out var value)) { - /// // `value` is of type `SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput` - /// Console.WriteLine(value); - /// } - /// - /// - /// - public bool TryPickEventOutput( - [NotNullWhen(true)] - out SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput? value + public SubscriptionSchedulePlanChangeParamsReplacePricePrice( + NewSubscriptionThresholdTotalAmountPrice value, + JsonElement? element = null ) { - value = this.Value as SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput; - return value != null; + this.Value = value; + this._element = element; } - /// - /// Calls the function parameter corresponding to the variant the instance was constructed with. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you need your function parameters to return something. - /// - /// - /// Thrown when the instance was constructed with an unknown variant (e.g. deserialized from raw data - /// that doesn't match any variant's expected shape). - /// - /// - /// - /// - /// instance.Switch( - /// (NewSubscriptionUnitPrice value) => {...}, - /// (NewSubscriptionTieredPrice value) => {...}, - /// (NewSubscriptionBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value) => {...}, - /// (NewSubscriptionPackagePrice value) => {...}, - /// (NewSubscriptionMatrixPrice value) => {...}, - /// (NewSubscriptionThresholdTotalAmountPrice value) => {...}, - /// (NewSubscriptionTieredPackagePrice value) => {...}, - /// (NewSubscriptionTieredWithMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedTieredPrice value) => {...}, - /// (NewSubscriptionTieredPackageWithMinimumPrice value) => {...}, - /// (NewSubscriptionPackageWithAllocationPrice value) => {...}, - /// (NewSubscriptionUnitWithPercentPrice value) => {...}, - /// (NewSubscriptionMatrixWithAllocationPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value) => {...}, - /// (NewSubscriptionUnitWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedAllocationPrice value) => {...}, - /// (NewSubscriptionBulkWithProrationPrice value) => {...}, - /// (NewSubscriptionGroupedWithProratedMinimumPrice value) => {...}, - /// (NewSubscriptionGroupedWithMeteredMinimumPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value) => {...}, - /// (NewSubscriptionMatrixWithDisplayNamePrice value) => {...}, - /// (NewSubscriptionGroupedTieredPackagePrice value) => {...}, - /// (NewSubscriptionMaxGroupTieredPackagePrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithUnitPricingPrice value) => {...}, - /// (NewSubscriptionScalableMatrixWithTieredPricingPrice value) => {...}, - /// (NewSubscriptionCumulativeGroupedBulkPrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value) => {...}, - /// (NewSubscriptionMinimumCompositePrice value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value) => {...}, - /// (SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value) => {...} - /// ); - /// - /// - /// - public void Switch( - System::Action newSubscriptionUnit, - System::Action newSubscriptionTiered, + 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( + 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.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) => {...}, + /// (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, @@ -13281,1271 +14908,2358 @@ 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 ) { - switch (this.Value) - { - case NewSubscriptionUnitPrice value: - newSubscriptionUnit(value); - break; - case NewSubscriptionTieredPrice value: - newSubscriptionTiered(value); - break; - case NewSubscriptionBulkPrice value: - newSubscriptionBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: - bulkWithFilters(value); - break; - case NewSubscriptionPackagePrice value: - newSubscriptionPackage(value); - break; - case NewSubscriptionMatrixPrice value: - newSubscriptionMatrix(value); - break; - case NewSubscriptionThresholdTotalAmountPrice value: - newSubscriptionThresholdTotalAmount(value); - break; - case NewSubscriptionTieredPackagePrice value: - newSubscriptionTieredPackage(value); - break; - case NewSubscriptionTieredWithMinimumPrice value: - newSubscriptionTieredWithMinimum(value); - break; - case NewSubscriptionGroupedTieredPrice value: - newSubscriptionGroupedTiered(value); - break; - case NewSubscriptionTieredPackageWithMinimumPrice value: - newSubscriptionTieredPackageWithMinimum(value); - break; - case NewSubscriptionPackageWithAllocationPrice value: - newSubscriptionPackageWithAllocation(value); - break; - case NewSubscriptionUnitWithPercentPrice value: - newSubscriptionUnitWithPercent(value); - break; - case NewSubscriptionMatrixWithAllocationPrice value: - newSubscriptionMatrixWithAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: - tieredWithProration(value); - break; - case NewSubscriptionUnitWithProrationPrice value: - newSubscriptionUnitWithProration(value); - break; - case NewSubscriptionGroupedAllocationPrice value: - newSubscriptionGroupedAllocation(value); - break; - case NewSubscriptionBulkWithProrationPrice value: - newSubscriptionBulkWithProration(value); - break; - case NewSubscriptionGroupedWithProratedMinimumPrice value: - newSubscriptionGroupedWithProratedMinimum(value); - break; - case NewSubscriptionGroupedWithMeteredMinimumPrice value: - newSubscriptionGroupedWithMeteredMinimum(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: - groupedWithMinMaxThresholds(value); - break; - case NewSubscriptionMatrixWithDisplayNamePrice value: - newSubscriptionMatrixWithDisplayName(value); - break; - case NewSubscriptionGroupedTieredPackagePrice value: - newSubscriptionGroupedTieredPackage(value); - break; - case NewSubscriptionMaxGroupTieredPackagePrice value: - newSubscriptionMaxGroupTieredPackage(value); - break; - case NewSubscriptionScalableMatrixWithUnitPricingPrice value: - newSubscriptionScalableMatrixWithUnitPricing(value); - break; - case NewSubscriptionScalableMatrixWithTieredPricingPrice value: - newSubscriptionScalableMatrixWithTieredPricing(value); - break; - case NewSubscriptionCumulativeGroupedBulkPrice value: - newSubscriptionCumulativeGroupedBulk(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: - cumulativeGroupedAllocation(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value: - minimum(value); - break; - case NewSubscriptionMinimumCompositePrice value: - newSubscriptionMinimumComposite(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value: - percent(value); - break; - case SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value: - eventOutput(value); - break; - default: - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); + switch (this.Value) + { + case NewSubscriptionUnitPrice value: + newSubscriptionUnit(value); + break; + case NewSubscriptionTieredPrice value: + newSubscriptionTiered(value); + break; + case NewSubscriptionBulkPrice value: + newSubscriptionBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters value: + bulkWithFilters(value); + break; + case NewSubscriptionPackagePrice value: + newSubscriptionPackage(value); + break; + case NewSubscriptionMatrixPrice value: + newSubscriptionMatrix(value); + break; + case NewSubscriptionThresholdTotalAmountPrice value: + newSubscriptionThresholdTotalAmount(value); + break; + case NewSubscriptionTieredPackagePrice value: + newSubscriptionTieredPackage(value); + break; + case NewSubscriptionTieredWithMinimumPrice value: + newSubscriptionTieredWithMinimum(value); + break; + case NewSubscriptionGroupedTieredPrice value: + newSubscriptionGroupedTiered(value); + break; + case NewSubscriptionTieredPackageWithMinimumPrice value: + newSubscriptionTieredPackageWithMinimum(value); + break; + case NewSubscriptionPackageWithAllocationPrice value: + newSubscriptionPackageWithAllocation(value); + break; + case NewSubscriptionUnitWithPercentPrice value: + newSubscriptionUnitWithPercent(value); + break; + case NewSubscriptionMatrixWithAllocationPrice value: + newSubscriptionMatrixWithAllocation(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration value: + tieredWithProration(value); + break; + case NewSubscriptionUnitWithProrationPrice value: + newSubscriptionUnitWithProration(value); + break; + case NewSubscriptionGroupedAllocationPrice value: + newSubscriptionGroupedAllocation(value); + break; + case NewSubscriptionBulkWithProrationPrice value: + newSubscriptionBulkWithProration(value); + break; + case NewSubscriptionGroupedWithProratedMinimumPrice value: + newSubscriptionGroupedWithProratedMinimum(value); + break; + case NewSubscriptionGroupedWithMeteredMinimumPrice value: + newSubscriptionGroupedWithMeteredMinimum(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value: + groupedWithMinMaxThresholds(value); + break; + case NewSubscriptionMatrixWithDisplayNamePrice value: + newSubscriptionMatrixWithDisplayName(value); + break; + case NewSubscriptionGroupedTieredPackagePrice value: + newSubscriptionGroupedTieredPackage(value); + break; + case NewSubscriptionMaxGroupTieredPackagePrice value: + newSubscriptionMaxGroupTieredPackage(value); + break; + case NewSubscriptionScalableMatrixWithUnitPricingPrice value: + newSubscriptionScalableMatrixWithUnitPricing(value); + break; + case NewSubscriptionScalableMatrixWithTieredPricingPrice value: + newSubscriptionScalableMatrixWithTieredPricing(value); + break; + case NewSubscriptionCumulativeGroupedBulkPrice value: + newSubscriptionCumulativeGroupedBulk(value); + break; + case SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value: + cumulativeGroupedAllocation(value); + break; + case 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) => {...}, + /// (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< + 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 + ), + 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( + 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(), + (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, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration _ => 14, + NewSubscriptionUnitWithProrationPrice _ => 15, + NewSubscriptionGroupedAllocationPrice _ => 16, + NewSubscriptionBulkWithProrationPrice _ => 17, + NewSubscriptionGroupedWithProratedMinimumPrice _ => 18, + NewSubscriptionGroupedWithMeteredMinimumPrice _ => 19, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds _ => + 20, + NewSubscriptionMatrixWithDisplayNamePrice _ => 21, + NewSubscriptionGroupedTieredPackagePrice _ => 22, + NewSubscriptionMaxGroupTieredPackagePrice _ => 23, + NewSubscriptionScalableMatrixWithUnitPricingPrice _ => 24, + NewSubscriptionScalableMatrixWithTieredPricingPrice _ => 25, + NewSubscriptionCumulativeGroupedBulkPrice _ => 26, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation _ => + 27, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance _ => 28, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance _ => 29, + NewSubscriptionMinimumCompositePrice _ => 30, + SubscriptionSchedulePlanChangeParamsReplacePricePricePercent _ => 31, + SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput _ => 32, + _ => -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 "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 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); } } /// - /// Calls the function parameter corresponding to the variant the instance was constructed with and - /// returns its result. - /// - /// Use the TryPick method(s) if you don't need to handle every variant, or - /// if you don't need your function parameters to return a value. - /// - /// - /// Thrown when the instance was 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) => {...} - /// ); - /// - /// + /// The cadence to bill for this price on. /// - 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 required ApiEnum< + string, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + > Cadence { - return this.Value switch + get { - 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" - ), - }; + 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); } } - 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); + /// + /// For custom cadence: specifies the duration of the billing period in days + /// 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackagePrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixPrice value - ) => new(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); } + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionThresholdTotalAmountPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackagePrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredWithMinimumPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionTieredPackageWithMinimumPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionPackageWithAllocationPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithPercentPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithAllocationPrice 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration 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 SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionUnitWithProrationPrice value - ) => new(value); + /// + public override void Validate() + { + this.BulkWithFiltersConfig.Validate(); + this.Cadence.Validate(); + _ = this.ItemID; + if ( + !JsonElement.DeepEquals( + this.ModelType, + JsonSerializer.SerializeToElement("bulk_with_filters") + ) + ) + { + throw new OrbInvalidDataException("Invalid value given for constant"); + } + _ = this.Name; + _ = this.BillableMetricID; + _ = this.BilledInAdvance; + this.BillingCycleConfiguration?.Validate(); + _ = this.ConversionRate; + this.ConversionRateConfig?.Validate(); + _ = this.Currency; + this.DimensionalPriceConfiguration?.Validate(); + _ = this.ExternalPriceID; + _ = this.FixedPriceQuantity; + _ = this.InvoiceGroupingKey; + this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; + _ = this.Metadata; + _ = this.ReferenceID; + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedAllocationPrice value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters() + { + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionBulkWithProrationPrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters + ) + : base(subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters) { } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithProratedMinimumPrice value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedWithMeteredMinimumPrice value - ) => new(value); + this.ModelType = JsonSerializer.SerializeToElement("bulk_with_filters"); + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMatrixWithDisplayNamePrice value - ) => new(value); + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionGroupedTieredPackagePrice value - ) => new(value); +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters.FromRawUnchecked( + rawData + ); +} - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMaxGroupTieredPackagePrice value - ) => new(value); +/// +/// 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)); + } + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithUnitPricingPrice value - ) => new(value); + /// + /// Bulk tiers for rating based on total usage volume + /// + public required IReadOnlyList Tiers + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullStruct< + ImmutableArray + >("tiers"); + } + init + { + this._rawData.Set< + ImmutableArray + >("tiers", ImmutableArray.ToImmutableArray(value)); + } + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionScalableMatrixWithTieredPricingPrice value - ) => new(value); + /// + public override void Validate() + { + foreach (var item in this.Filters) + { + item.Validate(); + } + foreach (var item in this.Tiers) + { + item.Validate(); + } + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionCumulativeGroupedBulkPrice value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig() + { } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig + ) { } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum value - ) => new(value); + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - NewSubscriptionMinimumCompositePrice value - ) => new(value); +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePricePercent value - ) => new(value); + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfig FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } +} - public static implicit operator SubscriptionSchedulePlanChangeParamsReplacePricePrice( - SubscriptionSchedulePlanChangeParamsReplacePricePriceEventOutput value - ) => new(value); +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 +{ /// - /// Validates that the instance was constructed with a known variant and that this variant is valid - /// (based on its own Validate method). - /// - /// This is useful for instances constructed from raw JSON data (e.g. deserialized from an API response). - /// - /// - /// Thrown when the instance does not pass validation. - /// + /// Event property key to filter on /// - public override void Validate() + public required string PropertyKey { - if (this.Value == null) + get { - throw new OrbInvalidDataException( - "Data did not match any variant of SubscriptionSchedulePlanChangeParamsReplacePricePrice" - ); - } - this.Switch( - (newSubscriptionUnit) => newSubscriptionUnit.Validate(), - (newSubscriptionTiered) => newSubscriptionTiered.Validate(), - (newSubscriptionBulk) => newSubscriptionBulk.Validate(), - (bulkWithFilters) => bulkWithFilters.Validate(), - (newSubscriptionPackage) => newSubscriptionPackage.Validate(), - (newSubscriptionMatrix) => newSubscriptionMatrix.Validate(), - (newSubscriptionThresholdTotalAmount) => newSubscriptionThresholdTotalAmount.Validate(), - (newSubscriptionTieredPackage) => newSubscriptionTieredPackage.Validate(), - (newSubscriptionTieredWithMinimum) => newSubscriptionTieredWithMinimum.Validate(), - (newSubscriptionGroupedTiered) => newSubscriptionGroupedTiered.Validate(), - (newSubscriptionTieredPackageWithMinimum) => - newSubscriptionTieredPackageWithMinimum.Validate(), - (newSubscriptionPackageWithAllocation) => - newSubscriptionPackageWithAllocation.Validate(), - (newSubscriptionUnitWithPercent) => newSubscriptionUnitWithPercent.Validate(), - (newSubscriptionMatrixWithAllocation) => newSubscriptionMatrixWithAllocation.Validate(), - (tieredWithProration) => tieredWithProration.Validate(), - (newSubscriptionUnitWithProration) => newSubscriptionUnitWithProration.Validate(), - (newSubscriptionGroupedAllocation) => newSubscriptionGroupedAllocation.Validate(), - (newSubscriptionBulkWithProration) => newSubscriptionBulkWithProration.Validate(), - (newSubscriptionGroupedWithProratedMinimum) => - newSubscriptionGroupedWithProratedMinimum.Validate(), - (newSubscriptionGroupedWithMeteredMinimum) => - newSubscriptionGroupedWithMeteredMinimum.Validate(), - (groupedWithMinMaxThresholds) => groupedWithMinMaxThresholds.Validate(), - (newSubscriptionMatrixWithDisplayName) => - newSubscriptionMatrixWithDisplayName.Validate(), - (newSubscriptionGroupedTieredPackage) => newSubscriptionGroupedTieredPackage.Validate(), - (newSubscriptionMaxGroupTieredPackage) => - newSubscriptionMaxGroupTieredPackage.Validate(), - (newSubscriptionScalableMatrixWithUnitPricing) => - newSubscriptionScalableMatrixWithUnitPricing.Validate(), - (newSubscriptionScalableMatrixWithTieredPricing) => - newSubscriptionScalableMatrixWithTieredPricing.Validate(), - (newSubscriptionCumulativeGroupedBulk) => - newSubscriptionCumulativeGroupedBulk.Validate(), - (cumulativeGroupedAllocation) => cumulativeGroupedAllocation.Validate(), - (minimum) => minimum.Validate(), - (newSubscriptionMinimumComposite) => newSubscriptionMinimumComposite.Validate(), - (percent) => percent.Validate(), - (eventOutput) => eventOutput.Validate() - ); + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_key"); + } + init { this._rawData.Set("property_key", value); } } - public virtual bool Equals(SubscriptionSchedulePlanChangeParamsReplacePricePrice? other) + /// + /// Event property value to match + /// + public required string PropertyValue { - return other != null && JsonElement.DeepEquals(this.Json, other.Json); + get + { + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("property_value"); + } + init { this._rawData.Set("property_value", value); } } - public override int GetHashCode() + /// + public override void Validate() { - return 0; + _ = this.PropertyKey; + _ = this.PropertyValue; } - public override string ToString() => - JsonSerializer.Serialize(this._element, ModelBase.ToStringSerializerOptions); + 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)); + } } -sealed class SubscriptionSchedulePlanChangeParamsReplacePricePriceConverter - : JsonConverter +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilterFromRaw + : IFromRawJson { - public override SubscriptionSchedulePlanChangeParamsReplacePricePrice? Read( - ref Utf8JsonReader reader, - System::Type typeToConvert, - JsonSerializerOptions options - ) + /// + 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 { - var element = JsonSerializer.Deserialize(ref reader, options); - string? modelType; - try - { - modelType = element.GetProperty("model_type").GetString(); - } - catch + get { - modelType = null; + this._rawData.Freeze(); + return this._rawData.GetNotNullClass("unit_amount"); } + init { this._rawData.Set("unit_amount", value); } + } - switch (modelType) + /// + /// The lower bound for this tier + /// + public string? TierLowerBound + { + 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 - } + this._rawData.Freeze(); + return this._rawData.GetNullableClass("tier_lower_bound"); + } + init { this._rawData.Set("tier_lower_bound", 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 - } + /// + public override void Validate() + { + _ = this.UnitAmount; + _ = this.TierLowerBound; + } - return new(element); - } - case "matrix": - { - try - { - var deserialized = JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier() + { } - 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 - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) + : base( + subscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier + ) { } +#pragma warning restore CS8618 - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + IReadOnlyDictionary rawData + ) + { + this._rawData = new(rawData); + } - return new(element); - } - case "tiered_with_minimum": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } +#pragma warning disable CS8618 + [SetsRequiredMembers] + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + FrozenDictionary rawData + ) + { + this._rawData = new(rawData); + } +#pragma warning restore CS8618 - 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 static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) + { + return new(FrozenDictionary.ToFrozenDictionary(rawData)); + } - 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 - } + [SetsRequiredMembers] + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + string unitAmount + ) + : this() + { + this.UnitAmount = unitAmount; + } +} - 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 - } +class SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTierFromRaw + : IFromRawJson +{ + /// + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier FromRawUnchecked( + IReadOnlyDictionary rawData + ) => + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier.FromRawUnchecked( + 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 - } +/// +/// The cadence to bill for this price on. +/// +[JsonConverter( + typeof(SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadenceConverter) +)] +public enum SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence +{ + Annual, + SemiAnnual, + Monthly, + Quarterly, + OneTime, + Custom, +} - return new(element); - } - case "matrix_with_allocation": +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 { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + 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; - 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 - } + JsonElement? _element = 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 - } + public JsonElement Json + { + get + { + return this._element ??= JsonSerializer.SerializeToElement( + this.Value, + ModelBase.SerializerOptions + ); + } + } - return new(element); - } - case "grouped_allocation": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedUnitConversionRateConfig value, + JsonElement? element = null + ) + { + this.Value = value; + this._element = element; + } - return new(element); - } - case "bulk_with_proration": - { - try - { - var deserialized = - JsonSerializer.Deserialize( - element, - options - ); - if (deserialized != null) - { - deserialized.Validate(); - return new(deserialized, element); - } - } - catch (System::Exception e) - when (e is JsonException || e is OrbInvalidDataException) - { - // ignore - } + public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + SharedTieredConversionRateConfig 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + } - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ), + }; + } - 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + 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 SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig" + ); + } + 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( + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig? 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 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 - ); + var deserialized = 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 +17268,38 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePrice(element); + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + element + ); } } } public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePrice? value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig 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 +17308,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence > >("cadence"); } @@ -14653,6 +17354,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 +17428,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 +17524,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +17575,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 +17599,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 +17636,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFilters FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -14912,187 +17645,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 +17797,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigFilter( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfig( FrozenDictionary rawData ) { @@ -15109,83 +17805,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 +17902,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersBulkWithFiltersConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( FrozenDictionary rawData ) { @@ -15202,114 +17910,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 +17952,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -15336,7 +17961,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -15345,7 +17970,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConve this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( JsonElement element ) { @@ -15356,7 +17981,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 +18002,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18022,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18033,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15429,7 +18054,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 +18063,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18074,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -15465,16 +18090,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 +18118,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 +18137,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 +18185,10 @@ JsonSerializerOptions 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 +18205,10 @@ JsonSerializerOptions 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 +18217,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( element ); } @@ -15592,7 +18226,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceBulkWithFiltersConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, JsonSerializerOptions options ) { @@ -15602,11 +18236,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds : JsonModel { /// @@ -15614,7 +18248,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence > Cadence { get @@ -15623,13 +18257,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 +18318,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 +18377,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 +18473,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +18525,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 +18548,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 +18585,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -15943,14 +18594,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProration.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( rawData ); } @@ -15959,9 +18610,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 +18622,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 +18634,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 +18662,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 +18778,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier( + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( FrozenDictionary rawData ) { @@ -16202,8 +18786,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationTieredWithProrationConfigTier FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16211,22 +18795,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 +18828,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -16253,7 +18837,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -16262,7 +18846,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationC this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( JsonElement element ) { @@ -16273,7 +18857,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 +18878,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +18898,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +18909,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16346,7 +18930,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 +18939,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +18950,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -16382,16 +18966,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 +18994,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 +19013,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 +19061,10 @@ JsonSerializerOptions 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 +19081,10 @@ JsonSerializerOptions 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 +19093,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( element ); } @@ -16509,7 +19102,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceTieredWithProrationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, JsonSerializerOptions options ) { @@ -16519,11 +19112,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation : JsonModel { /// @@ -16531,7 +19124,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > Cadence { get @@ -16540,7 +19133,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence > >("cadence"); } @@ -16548,18 +19141,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 +19253,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 +19349,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +19401,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 +19424,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 +19461,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -16860,14 +19470,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholds.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( rawData ); } @@ -16876,9 +19486,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 +19498,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 +19510,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 +19530,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsCadence value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence value, JsonSerializerOptions options ) { @@ -16928,17 +19538,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 +19560,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 +19654,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( FrozenDictionary rawData ) { @@ -17049,8 +19662,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsGroupedWithMinMaxThresholdsConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17058,22 +19671,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 +19704,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17100,7 +19713,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17109,7 +19722,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThr this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( JsonElement element ) { @@ -17120,7 +19733,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 +19754,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +19774,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +19785,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17193,7 +19806,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 +19815,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +19826,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -17229,16 +19842,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 +19870,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 +19889,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 +19937,10 @@ JsonSerializerOptions 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 +19957,10 @@ JsonSerializerOptions 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 +19969,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( element ); } @@ -17356,7 +19978,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceGroupedWithMinMaxThresholdsConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, JsonSerializerOptions options ) { @@ -17366,11 +19988,11 @@ JsonSerializerOptions options [JsonConverter( typeof(JsonModelConverter< - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceFromRaw >) )] -public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation +public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance : JsonModel { /// @@ -17378,7 +20000,7 @@ public sealed record class SubscriptionSchedulePlanChangeParamsReplacePricePrice /// public required ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > Cadence { get @@ -17387,7 +20009,7 @@ public required ApiEnum< return this._rawData.GetNotNullClass< ApiEnum< string, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCadence + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceCadence > >("cadence"); } @@ -17395,18 +20017,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 +20129,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 +20225,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +20277,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 +20300,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 +20337,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17707,14 +20346,14 @@ IReadOnlyDictionary rawData } } -class SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationFromRaw - : IFromRawJson +class SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceFromRaw + : IFromRawJson { /// - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation FromRawUnchecked( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) => - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocation.FromRawUnchecked( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowance.FromRawUnchecked( rawData ); } @@ -17723,9 +20362,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 +20374,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 +20386,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 +20413,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 +20435,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 +20638,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 +20664,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue( FrozenDictionary rawData ) { @@ -17896,8 +20672,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationCumulativeGroupedAllocationConfig FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceDailyCreditAllowanceConfigMatrixValue FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -17905,22 +20681,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 +20714,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -17947,7 +20723,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -17956,7 +20732,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAll this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( JsonElement element ) { @@ -17967,7 +20743,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 +20764,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +20784,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +20795,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18040,7 +20816,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 +20825,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +20836,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18076,16 +20852,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 +20880,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 +20899,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 +20947,10 @@ JsonSerializerOptions 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 +20967,10 @@ JsonSerializerOptions 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 +20979,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig( element ); } @@ -18203,7 +20988,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceCumulativeGroupedAllocationConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceDailyCreditAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -18213,25 +20998,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 +21040,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 +21139,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 +21235,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +21288,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 +21310,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 +21347,8 @@ FrozenDictionary rawData } #pragma warning restore CS8618 - /// - public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimum FromRawUnchecked( + /// + public static SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowance FromRawUnchecked( IReadOnlyDictionary rawData ) { @@ -18545,22 +21356,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 +21384,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 +21395,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 +21421,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 +21443,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 +21549,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 +21586,7 @@ IReadOnlyDictionary rawData #pragma warning disable CS8618 [SetsRequiredMembers] - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumMinimumConfig( + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceMeteredAllowanceConfig( FrozenDictionary rawData ) { @@ -18703,40 +21594,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 +21636,7 @@ public JsonElement Json } } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedUnitConversionRateConfig value, JsonElement? element = null ) @@ -18763,7 +21645,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( SharedTieredConversionRateConfig value, JsonElement? element = null ) @@ -18772,7 +21654,7 @@ public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRat this._element = element; } - public SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + public SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( JsonElement element ) { @@ -18783,7 +21665,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 +21686,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +21706,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +21717,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18856,7 +21738,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 +21747,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +21758,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -18892,16 +21774,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 +21802,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 +21821,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 +21869,10 @@ JsonSerializerOptions 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 +21889,10 @@ JsonSerializerOptions 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 +21901,7 @@ JsonSerializerOptions options } default: { - return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig( + return new SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig( element ); } @@ -19019,7 +21910,7 @@ JsonSerializerOptions options public override void Write( Utf8JsonWriter writer, - SubscriptionSchedulePlanChangeParamsReplacePricePriceMinimumConversionRateConfig value, + SubscriptionSchedulePlanChangeParamsReplacePricePriceMeteredAllowanceConversionRateConfig value, JsonSerializerOptions options ) { @@ -19262,6 +22153,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +22223,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -19328,10 +22233,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 +22383,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 +22486,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 +22507,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +22527,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +22538,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19657,7 +22568,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +22579,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -19720,10 +22631,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 +22642,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +22690,10 @@ JsonSerializerOptions 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 +22710,10 @@ JsonSerializerOptions 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 +22978,19 @@ public NewBillingCycleConfiguration? InvoicingCycleConfiguration init { this._rawData.Set("invoicing_cycle_configuration", value); } } + /// + /// The ID of the license type to associate with this price. + /// + public string? LicenseTypeID + { + get + { + this._rawData.Freeze(); + return this._rawData.GetNullableClass("license_type_id"); + } + init { this._rawData.Set("license_type_id", value); } + } + /// /// User-specified key/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 +23053,7 @@ public override void Validate() _ = this.FixedPriceQuantity; _ = this.InvoiceGroupingKey; this.InvoicingCycleConfiguration?.Validate(); + _ = this.LicenseTypeID; _ = this.Metadata; _ = this.ReferenceID; } @@ -20129,10 +23063,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 +23246,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 +23352,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 +23373,7 @@ public bool TryPickUnit([NotNullWhen(true)] out SharedUnitConversionRateConfig? /// Returns true and sets the out parameter if the instance was constructed with 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 +23393,7 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// Calls the function parameter corresponding to the variant the instance was constructed with. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// 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 +23404,8 @@ public bool TryPickTiered([NotNullWhen(true)] out SharedTieredConversionRateConf /// /// /// instance.Switch( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20494,7 +23434,7 @@ public void Switch( /// Calls the function parameter corresponding to the variant the instance was constructed with and /// returns its result. /// - /// Use the TryPick method(s) if you don't need to handle every variant, or + /// Use the TryPick 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 +23445,8 @@ public void Switch( /// /// /// var result = instance.Match( - /// (SharedUnitConversionRateConfig value) => {...}, - /// (SharedTieredConversionRateConfig value) => {...} + /// (SharedUnitConversionRateConfig value) => {...}, + /// (SharedTieredConversionRateConfig value) => {...} /// ); /// /// @@ -20557,10 +23497,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 +23508,20 @@ public override int GetHashCode() } public override string ToString() => - JsonSerializer.Serialize(this._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 +23556,10 @@ JsonSerializerOptions 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 +23576,10 @@ JsonSerializerOptions 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..3467ea277 100644 --- a/src/Orb/Services/Customers/Credits/ILedgerService.cs +++ b/src/Orb/Services/Customers/Credits/ILedgerService.cs @@ -7,9 +7,12 @@ namespace Orb.Services.Customers.Credits; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface ILedgerService { @@ -32,69 +35,70 @@ public interface ILedgerService /// balance. This [paginated endpoint](/api-reference/pagination) lists these /// entries, starting from the most recent ledger entry. /// - /// More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). + /// More details on using Orb's real-time credit feature are + /// [here](/product-catalog/prepurchase). /// - /// There are four major types of modifications to credit balance, detailed below. + /// There are four major types of modifications to credit balance, detailed + /// below. /// - /// ## Increment Credits (which optionally expire on a future date) can - /// be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger - /// entry for such an action will always contain the total eligible starting and - /// ending balance for the customer at the time the entry was added to the ledger. + /// ## Increment Credits (which optionally expire on a future date) can be + /// added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry + /// for such an action will always contain the total eligible starting and ending + /// balance for the customer at the time the entry was added to the ledger. /// - /// ## Decrement Deductions can occur as a result of an API call to create - /// a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically - /// as a result of incurring usage. Both ledger entries present the `decrement` - /// entry type. + /// ## Decrement Deductions can occur as a result of an API call to create a + /// ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as + /// a result of incurring usage. Both ledger entries present the `decrement` entry + /// type. /// /// As usage for a customer is reported into Orb, credits may be deducted - /// according to the customer's plan configuration. An automated deduction of - /// this type will result in a ledger entry, also with a starting and ending balance. - /// In order to provide better tracing capabilities for automatic deductions, - /// Orb always associates each automatic deduction with the `event_id` at the - /// time of ingestion, used to pinpoint _why_ credit deduction took place and - /// to ensure that credits are never deducted without an associated usage event. + /// according to the customer's plan configuration. An automated deduction of this + /// type will result in a ledger entry, also with a starting and ending balance. + /// Each day's usage for a particular price, invoice, and block will be grouped into + /// a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the - /// *soonest expiring credit block* first in order to ensure that all credits - /// are utilized appropriately. As an example, if trial credits with an expiration - /// date of 2 weeks from now are present for a customer, they will be used before - /// any deductions take place from a non-expiring credit block. + /// *soonest expiring credit block* first in order to ensure that all credits are + /// utilized appropriately. As an example, if trial credits with an expiration date + /// of 2 weeks from now are present for a customer, they will be used before any + /// deductions take place from a non-expiring credit block. /// /// If there are multiple blocks with the same expiration date, Orb will - /// deduct from the block with the *lower cost basis* first (e.g. trial credits - /// with a \$0 cost basis before paid credits with a \$5.00 cost basis). + /// deduct from the block with the *lower cost basis* first (e.g. trial credits with + /// a \$0 cost basis before paid credits with a \$5.00 cost basis). /// /// It's also possible for a single usage event's deduction to _span_ credit - /// blocks. In this case, Orb will deduct from the next block, ending at the - /// credit block which consists of unexpiring credits. Each of these deductions - /// will lead to a _separate_ ledger entry, one per credit block that is deducted - /// from. By default, the customer's total credit balance in Orb can be negative - /// as a result of a decrement. - /// - /// ## Expiration change The expiry of credits can be changed as a result - /// of the API (See [Add Ledger Entry](create-ledger-entry)). This will create - /// a ledger entry that specifies the balance as well as the initial and target - /// expiry dates. - /// - /// Note that for this entry type, `starting_balance` will equal `ending_balance`, - /// and the `amount` represents the balance transferred. The credit block linked - /// to the ledger entry is the source credit block from which there was an expiration change. - /// - /// ## Credits expiry When a set of credits expire on pre-set expiration - /// date, the customer's balance automatically reflects this change and adds - /// an entry to the ledger indicating this event. Note that credit expiry should - /// always happen close to a date boundary in the customer's timezone. - /// - /// ## Void initiated Credit blocks can be voided via the API. The `amount` - /// on this entry corresponds to the number of credits that were remaining in - /// the block at time of void. `void_reason` will be populated if the void is - /// created with a reason. - /// - /// ## Void When a set of credits is voided, the customer's balance automatically - /// reflects this change and adds an entry to the ledger indicating this event. - /// - /// ## Amendment When credits are added to a customer's balance as a result - /// of a correction, this entry will be added to the ledger to indicate the adjustment + /// blocks. In this case, Orb will deduct from the next block, ending at the credit + /// block which consists of unexpiring credits. Each of these deductions will lead + /// to a _separate_ ledger entry, one per credit block that is deducted from. By + /// default, the customer's total credit balance in Orb can be negative as a result + /// of a decrement. + /// + /// ## Expiration change The expiry of credits can be changed as a result of + /// the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger + /// entry that specifies the balance as well as the initial and target expiry dates. + /// + /// Note that for this entry type, `starting_balance` will equal + /// `ending_balance`, and the `amount` represents the balance transferred. The + /// credit block linked to the ledger entry is the source credit block from which + /// there was an expiration change. + /// + /// ## Credits expiry When a set of credits expire on pre-set expiration date, + /// the customer's balance automatically reflects this change and adds an entry to + /// the ledger indicating this event. Note that credit expiry should always happen + /// close to a date boundary in the customer's timezone. + /// + /// ## Void initiated Credit blocks can be voided via the API. The `amount` on + /// this entry corresponds to the number of credits that were remaining in the block + /// at time of void. `void_reason` will be populated if the void is created with a + /// reason. + /// + /// ## Void When a set of credits is voided, the customer's balance + /// automatically reflects this change and adds an entry to the ledger indicating + /// this event. + /// + /// ## Amendment When credits are added to a customer's balance as a result of + /// a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. /// Task List( @@ -111,75 +115,83 @@ Task List( /// /// This endpoint allows you to create a new ledger entry for a specified customer's - /// balance. This can be used to increment balance, deduct credits, and change - /// the expiry date of existing credits. - /// - /// ## Effects of adding a ledger entry 1. After calling this endpoint, - /// [Fetch Credit Balance](fetch-customer-credits) will return a credit block - /// that represents the changes (i.e. balance changes or transfers). 2. A ledger - /// entry will be added to the credits ledger for this customer, and therefore - /// returned in the [View Credits Ledger](fetch-customer-credits-ledger) response - /// as well as serialized in the response to this request. In the case of deductions - /// without a specified block, multiple ledger entries may be created if the deduction - /// spans credit blocks. 3. If `invoice_settings` is specified, an invoice - /// will be created that reflects the cost of the credits (based on `amount` - /// and `per_unit_cost_basis`). - /// - /// ## Adding credits Adding credits is done by creating an entry of - /// type `increment`. This requires the caller to specify a number of credits - /// as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends + /// balance. This can be used to increment balance, deduct credits, and change the + /// expiry date of existing credits. + /// + /// ## Effects of adding a ledger entry 1. After calling this endpoint, [Fetch + /// Credit Balance](fetch-customer-credits) will return a credit block that + /// represents the changes (i.e. balance changes or transfers). 2. A ledger entry + /// will be added to the credits ledger for this customer, and therefore returned in + /// the [View Credits Ledger](fetch-customer-credits-ledger) response as well as + /// serialized in the response to this request. In the case of deductions without + /// a specified block, multiple ledger entries may be created if the deduction spans + /// credit blocks. 3. If `invoice_settings` is specified, an invoice will be + /// created that reflects the cost of the credits (based on `amount` and + /// `per_unit_cost_basis`). + /// + /// ## Adding credits Adding credits is done by creating an entry of type + /// `increment`. This requires the caller to specify a number of credits as well + /// as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends /// specifying a description to assist with auditing. When adding credits, the - /// caller can also specify a cost basis per-credit, to indicate how much in - /// USD a customer paid for a single credit in a block. This can later be used - /// for revenue recognition. + /// caller can also specify a cost basis per-credit, to indicate how much in USD a + /// customer paid for a single credit in a block. This can later be used for revenue + /// recognition. /// /// The following snippet illustrates a sample request body to increment /// credits which will expire in January of 2022. /// /// ```json { "entry_type": "increment", "amount": 100, "expiry_date": - /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased - /// 100 credits" } ``` + /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased 100 + /// credits" } ``` /// /// Note that by default, Orb will always first increment any _negative_ /// balance in existing blocks before adding the remaining amount to the desired /// credit block. /// /// ### Invoicing for credits By default, Orb manipulates the credit ledger - /// but does not charge for credits. However, if you pass `invoice_settings` - /// in the body of this request, Orb will also generate a one-off invoice for - /// the customer for the credits pre-purchase. Note that you _must_ provide the - /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. - /// - /// ## Deducting Credits Orb allows you to deduct credits from a customer - /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic - /// deductions for determining which credit blocks to decrement from. In the - /// case that the deduction leads to multiple ledger entries, the response from - /// this endpoint will be the final deduction. Orb also optionally allows specifying - /// a description to assist with auditing. - /// - /// The following snippet illustrates a sample request body to decrement credits. + /// but does not charge for credits. However, if you pass `invoice_settings` in the + /// body of this request, Orb will also generate a one-off invoice for the customer + /// for the credits pre-purchase. Note that you _must_ provide the + /// `per_unit_cost_basis`, since the total charges on the invoice are calculated by + /// multiplying the cost basis with the number of credit units added. If you invoice + /// or handle payment of credits outside of Orb (i.e. marketplace customers), set + /// `mark_as_paid` in the `invoice_settings` to `true` to prevent duplicate + /// invoicing effects. * if `per_unit_cost_basis` is greater than zero, an invoice + /// will be generated and `invoice_settings` must be included * if + /// `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is + /// required to determine the due date + /// + /// ## Deducting Credits Orb allows you to deduct credits from a customer by + /// creating an entry of type `decrement`. Orb matches the algorithm for automatic + /// deductions for determining which credit blocks to decrement from. In the case + /// that the deduction leads to multiple ledger entries, the response from this + /// endpoint will be the final deduction. Orb also optionally allows specifying a + /// description to assist with auditing. + /// + /// The following snippet illustrates a sample request body to decrement + /// credits. /// /// ```json { "entry_type": "decrement", "amount": 20, "description": /// "Removing excess credits" } ``` /// /// ## Changing credits expiry If you'd like to change when existing credits - /// expire, you should create a ledger entry of type `expiration_change`. For - /// this entry, the required parameter `expiry_date` identifies the _originating_ - /// block, and the required parameter `target_expiry_date` identifies when the - /// transferred credits should now expire. A new credit block will be created - /// with expiry date `target_expiry_date`, with the same cost basis data as the - /// original credit block, if present. + /// expire, you should create a ledger entry of type `expiration_change`. For this + /// entry, the required parameter `expiry_date` identifies the _originating_ block, + /// and the required parameter `target_expiry_date` identifies when the transferred + /// credits should now expire. A new credit block will be created with expiry date + /// `target_expiry_date`, with the same cost basis data as the original credit + /// block, if present. /// - /// Note that the balance of the block with the given `expiry_date` must - /// be at least equal to the desired transfer amount determined by the `amount` parameter. + /// Note that the balance of the block with the given `expiry_date` must be at + /// least equal to the desired transfer amount determined by the `amount` parameter. /// /// The following snippet illustrates a sample request body to extend the /// expiration date of credits by one year: /// - /// ```json { "entry_type": "expiration_change", "amount": 10, "expiry_date": - /// "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", "target_expiry_date": "2023-12-28", - /// "description": "Extending credit validity" } ``` + /// ```json { "entry_type": "expiration_change", "amount": 10, + /// "expiry_date": "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", + /// "target_expiry_date": "2023-12-28", "description": "Extending credit validity" + /// } ``` /// /// ## Voiding credits /// @@ -190,10 +202,10 @@ Task List( /// /// ## Amendment /// - /// If you'd like to undo a decrement on a credit block, create a ledger - /// entry of type `amendment`. For this entry, `block_id` is required to identify - /// the block that was originally decremented from, and `amount` indicates how - /// many credits to return to the customer, up to the block's initial balance. + /// If you'd like to undo a decrement on a credit block, create a ledger entry + /// of type `amendment`. For this entry, `block_id` is required to identify the + /// block that was originally decremented from, and `amount` indicates how many + /// credits to return to the customer, up to the block's initial balance. /// Task CreateEntry( LedgerCreateEntryParams parameters, @@ -209,75 +221,83 @@ Task CreateEntry( /// /// This endpoint allows you to create a new ledger entry for a specified customer's - /// balance. This can be used to increment balance, deduct credits, and change - /// the expiry date of existing credits. - /// - /// ## Effects of adding a ledger entry 1. After calling this endpoint, - /// [Fetch Credit Balance](fetch-customer-credits) will return a credit block - /// that represents the changes (i.e. balance changes or transfers). 2. A ledger - /// entry will be added to the credits ledger for this customer, and therefore - /// returned in the [View Credits Ledger](fetch-customer-credits-ledger) response - /// as well as serialized in the response to this request. In the case of deductions - /// without a specified block, multiple ledger entries may be created if the deduction - /// spans credit blocks. 3. If `invoice_settings` is specified, an invoice - /// will be created that reflects the cost of the credits (based on `amount` - /// and `per_unit_cost_basis`). - /// - /// ## Adding credits Adding credits is done by creating an entry of - /// type `increment`. This requires the caller to specify a number of credits - /// as well as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends + /// balance. This can be used to increment balance, deduct credits, and change the + /// expiry date of existing credits. + /// + /// ## Effects of adding a ledger entry 1. After calling this endpoint, [Fetch + /// Credit Balance](fetch-customer-credits) will return a credit block that + /// represents the changes (i.e. balance changes or transfers). 2. A ledger entry + /// will be added to the credits ledger for this customer, and therefore returned in + /// the [View Credits Ledger](fetch-customer-credits-ledger) response as well as + /// serialized in the response to this request. In the case of deductions without + /// a specified block, multiple ledger entries may be created if the deduction spans + /// credit blocks. 3. If `invoice_settings` is specified, an invoice will be + /// created that reflects the cost of the credits (based on `amount` and + /// `per_unit_cost_basis`). + /// + /// ## Adding credits Adding credits is done by creating an entry of type + /// `increment`. This requires the caller to specify a number of credits as well + /// as an optional expiry date in `YYYY-MM-DD` format. Orb also recommends /// specifying a description to assist with auditing. When adding credits, the - /// caller can also specify a cost basis per-credit, to indicate how much in - /// USD a customer paid for a single credit in a block. This can later be used - /// for revenue recognition. + /// caller can also specify a cost basis per-credit, to indicate how much in USD a + /// customer paid for a single credit in a block. This can later be used for revenue + /// recognition. /// /// The following snippet illustrates a sample request body to increment /// credits which will expire in January of 2022. /// /// ```json { "entry_type": "increment", "amount": 100, "expiry_date": - /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased - /// 100 credits" } ``` + /// "2022-12-28", "per_unit_cost_basis": "0.20", "description": "Purchased 100 + /// credits" } ``` /// /// Note that by default, Orb will always first increment any _negative_ /// balance in existing blocks before adding the remaining amount to the desired /// credit block. /// /// ### Invoicing for credits By default, Orb manipulates the credit ledger - /// but does not charge for credits. However, if you pass `invoice_settings` - /// in the body of this request, Orb will also generate a one-off invoice for - /// the customer for the credits pre-purchase. Note that you _must_ provide the - /// `per_unit_cost_basis`, since the total charges on the invoice are calculated - /// by multiplying the cost basis with the number of credit units added. - /// - /// ## Deducting Credits Orb allows you to deduct credits from a customer - /// by creating an entry of type `decrement`. Orb matches the algorithm for automatic - /// deductions for determining which credit blocks to decrement from. In the - /// case that the deduction leads to multiple ledger entries, the response from - /// this endpoint will be the final deduction. Orb also optionally allows specifying - /// a description to assist with auditing. - /// - /// The following snippet illustrates a sample request body to decrement credits. + /// but does not charge for credits. However, if you pass `invoice_settings` in the + /// body of this request, Orb will also generate a one-off invoice for the customer + /// for the credits pre-purchase. Note that you _must_ provide the + /// `per_unit_cost_basis`, since the total charges on the invoice are calculated by + /// multiplying the cost basis with the number of credit units added. If you invoice + /// or handle payment of credits outside of Orb (i.e. marketplace customers), set + /// `mark_as_paid` in the `invoice_settings` to `true` to prevent duplicate + /// invoicing effects. * if `per_unit_cost_basis` is greater than zero, an invoice + /// will be generated and `invoice_settings` must be included * if + /// `invoice_settings` is passed, one of either `custom_due_date` or `net_terms` is + /// required to determine the due date + /// + /// ## Deducting Credits Orb allows you to deduct credits from a customer by + /// creating an entry of type `decrement`. Orb matches the algorithm for automatic + /// deductions for determining which credit blocks to decrement from. In the case + /// that the deduction leads to multiple ledger entries, the response from this + /// endpoint will be the final deduction. Orb also optionally allows specifying a + /// description to assist with auditing. + /// + /// The following snippet illustrates a sample request body to decrement + /// credits. /// /// ```json { "entry_type": "decrement", "amount": 20, "description": /// "Removing excess credits" } ``` /// /// ## Changing credits expiry If you'd like to change when existing credits - /// expire, you should create a ledger entry of type `expiration_change`. For - /// this entry, the required parameter `expiry_date` identifies the _originating_ - /// block, and the required parameter `target_expiry_date` identifies when the - /// transferred credits should now expire. A new credit block will be created - /// with expiry date `target_expiry_date`, with the same cost basis data as the - /// original credit block, if present. + /// expire, you should create a ledger entry of type `expiration_change`. For this + /// entry, the required parameter `expiry_date` identifies the _originating_ block, + /// and the required parameter `target_expiry_date` identifies when the transferred + /// credits should now expire. A new credit block will be created with expiry date + /// `target_expiry_date`, with the same cost basis data as the original credit + /// block, if present. /// - /// Note that the balance of the block with the given `expiry_date` must - /// be at least equal to the desired transfer amount determined by the `amount` parameter. + /// Note that the balance of the block with the given `expiry_date` must be at + /// least equal to the desired transfer amount determined by the `amount` parameter. /// /// The following snippet illustrates a sample request body to extend the /// expiration date of credits by one year: /// - /// ```json { "entry_type": "expiration_change", "amount": 10, "expiry_date": - /// "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", "target_expiry_date": "2023-12-28", - /// "description": "Extending credit validity" } ``` + /// ```json { "entry_type": "expiration_change", "amount": 10, + /// "expiry_date": "2022-12-28", "block_id": "UiUhFWeLHPrBY4Ad", + /// "target_expiry_date": "2023-12-28", "description": "Extending credit validity" + /// } ``` /// /// ## Voiding credits /// @@ -288,10 +308,10 @@ Task CreateEntry( /// /// ## Amendment /// - /// If you'd like to undo a decrement on a credit block, create a ledger - /// entry of type `amendment`. For this entry, `block_id` is required to identify - /// the block that was originally decremented from, and `amount` indicates how - /// many credits to return to the customer, up to the block's initial balance. + /// If you'd like to undo a decrement on a credit block, create a ledger entry + /// of type `amendment`. For this entry, `block_id` is required to identify the + /// block that was originally decremented from, and `amount` indicates how many + /// credits to return to the customer, up to the block's initial balance. /// Task CreateEntryByExternalID( LedgerCreateEntryByExternalIDParams parameters, @@ -311,69 +331,70 @@ Task CreateEntryByExternalID( /// balance. This [paginated endpoint](/api-reference/pagination) lists these /// entries, starting from the most recent ledger entry. /// - /// More details on using Orb's real-time credit feature are [here](/product-catalog/prepurchase). + /// More details on using Orb's real-time credit feature are + /// [here](/product-catalog/prepurchase). /// - /// There are four major types of modifications to credit balance, detailed below. + /// There are four major types of modifications to credit balance, detailed + /// below. /// - /// ## Increment Credits (which optionally expire on a future date) can - /// be added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger - /// entry for such an action will always contain the total eligible starting and - /// ending balance for the customer at the time the entry was added to the ledger. + /// ## Increment Credits (which optionally expire on a future date) can be + /// added via the API ([Add Ledger Entry](create-ledger-entry)). The ledger entry + /// for such an action will always contain the total eligible starting and ending + /// balance for the customer at the time the entry was added to the ledger. /// - /// ## Decrement Deductions can occur as a result of an API call to create - /// a ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically - /// as a result of incurring usage. Both ledger entries present the `decrement` - /// entry type. + /// ## Decrement Deductions can occur as a result of an API call to create a + /// ledger entry (see [Add Ledger Entry](create-ledger-entry)), or automatically as + /// a result of incurring usage. Both ledger entries present the `decrement` entry + /// type. /// /// As usage for a customer is reported into Orb, credits may be deducted - /// according to the customer's plan configuration. An automated deduction of - /// this type will result in a ledger entry, also with a starting and ending balance. - /// In order to provide better tracing capabilities for automatic deductions, - /// Orb always associates each automatic deduction with the `event_id` at the - /// time of ingestion, used to pinpoint _why_ credit deduction took place and - /// to ensure that credits are never deducted without an associated usage event. + /// according to the customer's plan configuration. An automated deduction of this + /// type will result in a ledger entry, also with a starting and ending balance. + /// Each day's usage for a particular price, invoice, and block will be grouped into + /// a single entry. /// /// By default, Orb uses an algorithm that automatically deducts from the - /// *soonest expiring credit block* first in order to ensure that all credits - /// are utilized appropriately. As an example, if trial credits with an expiration - /// date of 2 weeks from now are present for a customer, they will be used before - /// any deductions take place from a non-expiring credit block. + /// *soonest expiring credit block* first in order to ensure that all credits are + /// utilized appropriately. As an example, if trial credits with an expiration date + /// of 2 weeks from now are present for a customer, they will be used before any + /// deductions take place from a non-expiring credit block. /// /// If there are multiple blocks with the same expiration date, Orb will - /// deduct from the block with the *lower cost basis* first (e.g. trial credits - /// with a \$0 cost basis before paid credits with a \$5.00 cost basis). + /// deduct from the block with the *lower cost basis* first (e.g. trial credits with + /// a \$0 cost basis before paid credits with a \$5.00 cost basis). /// /// It's also possible for a single usage event's deduction to _span_ credit - /// blocks. In this case, Orb will deduct from the next block, ending at the - /// credit block which consists of unexpiring credits. Each of these deductions - /// will lead to a _separate_ ledger entry, one per credit block that is deducted - /// from. By default, the customer's total credit balance in Orb can be negative - /// as a result of a decrement. - /// - /// ## Expiration change The expiry of credits can be changed as a result - /// of the API (See [Add Ledger Entry](create-ledger-entry)). This will create - /// a ledger entry that specifies the balance as well as the initial and target - /// expiry dates. - /// - /// Note that for this entry type, `starting_balance` will equal `ending_balance`, - /// and the `amount` represents the balance transferred. The credit block linked - /// to the ledger entry is the source credit block from which there was an expiration change. - /// - /// ## Credits expiry When a set of credits expire on pre-set expiration - /// date, the customer's balance automatically reflects this change and adds - /// an entry to the ledger indicating this event. Note that credit expiry should - /// always happen close to a date boundary in the customer's timezone. - /// - /// ## Void initiated Credit blocks can be voided via the API. The `amount` - /// on this entry corresponds to the number of credits that were remaining in - /// the block at time of void. `void_reason` will be populated if the void is - /// created with a reason. - /// - /// ## Void When a set of credits is voided, the customer's balance automatically - /// reflects this change and adds an entry to the ledger indicating this event. - /// - /// ## Amendment When credits are added to a customer's balance as a result - /// of a correction, this entry will be added to the ledger to indicate the adjustment + /// blocks. In this case, Orb will deduct from the next block, ending at the credit + /// block which consists of unexpiring credits. Each of these deductions will lead + /// to a _separate_ ledger entry, one per credit block that is deducted from. By + /// default, the customer's total credit balance in Orb can be negative as a result + /// of a decrement. + /// + /// ## Expiration change The expiry of credits can be changed as a result of + /// the API (See [Add Ledger Entry](create-ledger-entry)). This will create a ledger + /// entry that specifies the balance as well as the initial and target expiry dates. + /// + /// Note that for this entry type, `starting_balance` will equal + /// `ending_balance`, and the `amount` represents the balance transferred. The + /// credit block linked to the ledger entry is the source credit block from which + /// there was an expiration change. + /// + /// ## Credits expiry When a set of credits expire on pre-set expiration date, + /// the customer's balance automatically reflects this change and adds an entry to + /// the ledger indicating this event. Note that credit expiry should always happen + /// close to a date boundary in the customer's timezone. + /// + /// ## Void initiated Credit blocks can be voided via the API. The `amount` on + /// this entry corresponds to the number of credits that were remaining in the block + /// at time of void. `void_reason` will be populated if the void is created with a + /// reason. + /// + /// ## Void When a set of credits is voided, the customer's balance + /// automatically reflects this change and adds an entry to the ledger indicating + /// this event. + /// + /// ## Amendment When credits are added to a customer's balance as a result of + /// a correction, this entry will be added to the ledger to indicate the adjustment /// of credits. /// Task ListByExternalID( @@ -403,7 +424,7 @@ public interface ILedgerServiceWithRawResponse ILedgerServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits/ledger`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits/ledger, but is otherwise the /// same as . /// Task> List( @@ -419,7 +440,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/credits/ledger_entry`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/credits/ledger_entry, but is otherwise the /// same as . /// Task> CreateEntry( @@ -435,7 +456,7 @@ Task> CreateEntry( ); /// - /// Returns a raw HTTP response for `post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry`, but is otherwise the + /// Returns a raw HTTP response for post /customers/external_customer_id/{external_customer_id}/credits/ledger_entry, but is otherwise the /// same as . /// Task> CreateEntryByExternalID( @@ -451,7 +472,7 @@ Task> CreateEntryByExternalI ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits/ledger`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits/ledger, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/Credits/ITopUpService.cs b/src/Orb/Services/Customers/Credits/ITopUpService.cs index c7f766c6d..6fbafc0b1 100644 --- a/src/Orb/Services/Customers/Credits/ITopUpService.cs +++ b/src/Orb/Services/Customers/Credits/ITopUpService.cs @@ -7,9 +7,12 @@ namespace Orb.Services.Customers.Credits; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface ITopUpService { @@ -29,10 +32,11 @@ public interface ITopUpService /// /// This endpoint allows you to create a new top-up for a specified customer's /// balance. While this top-up is active, the customer's balance will added in - /// increments of the specified amount whenever the balance reaches the specified threshold. + /// increments of the specified amount whenever the balance reaches the specified + /// threshold. /// - /// If a top-up already exists for this customer in the same currency, - /// the existing top-up will be replaced. + /// If a top-up already exists for this customer in the same currency, the + /// existing top-up will be replaced. /// Task Create( TopUpCreateParams parameters, @@ -77,10 +81,11 @@ Task Delete( /// /// This endpoint allows you to create a new top-up for a specified customer's /// balance. While this top-up is active, the customer's balance will added in - /// increments of the specified amount whenever the balance reaches the specified threshold. + /// increments of the specified amount whenever the balance reaches the specified + /// threshold. /// - /// If a top-up already exists for this customer in the same currency, - /// the existing top-up will be replaced. + /// If a top-up already exists for this customer in the same currency, the + /// existing top-up will be replaced. /// Task CreateByExternalID( TopUpCreateByExternalIDParams parameters, @@ -140,7 +145,7 @@ public interface ITopUpServiceWithRawResponse ITopUpServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> Create( @@ -156,7 +161,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> List( @@ -172,7 +177,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `delete /customers/{customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /customers/{customer_id}/credits/top_ups/{top_up_id}, but is otherwise the /// same as . /// Task Delete( @@ -188,7 +193,7 @@ Task Delete( ); /// - /// Returns a raw HTTP response for `post /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for post /customers/external_customer_id/{external_customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> CreateByExternalID( @@ -204,7 +209,7 @@ Task> CreateByExternalID( ); /// - /// Returns a raw HTTP response for `delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}`, but is otherwise the + /// Returns a raw HTTP response for delete /customers/external_customer_id/{external_customer_id}/credits/top_ups/{top_up_id}, but is otherwise the /// same as . /// Task DeleteByExternalID( @@ -220,7 +225,7 @@ Task DeleteByExternalID( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits/top_ups`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits/top_ups, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/IBalanceTransactionService.cs b/src/Orb/Services/Customers/IBalanceTransactionService.cs index c2ab67eab..05d7481a1 100644 --- a/src/Orb/Services/Customers/IBalanceTransactionService.cs +++ b/src/Orb/Services/Customers/IBalanceTransactionService.cs @@ -7,9 +7,25 @@ namespace Orb.Services.Customers; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// A customer is a buyer of your products, and the other party to the billing relationship. +/// +/// In Orb, customers are assigned system generated identifiers automatically, +/// but it's often desirable to have these match existing identifiers in your system. +/// To avoid having to denormalize Orb ID information, you can pass in an `external_customer_id` +/// with your own identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) +/// for further information about how these aliases work in Orb. +/// +/// In addition to having an identifier in your system, a customer may exist +/// in a payment provider solution like Stripe. Use the `payment_provider_id` and +/// the `payment_provider` enum field to express this mapping. +/// +/// A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), +/// which defaults to your account's timezone. See [Timezone localization](/essentials/timezones) +/// for information on what this timezone parameter influences within Orb. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IBalanceTransactionService { @@ -27,8 +43,8 @@ public interface IBalanceTransactionService IBalanceTransactionService WithOptions(Func modifier); /// - /// Creates an immutable balance transaction that updates the customer's balance - /// and returns back the newly created transaction. + /// Creates an immutable balance transaction that updates the customer's balance and + /// returns back the newly created transaction. /// Task Create( BalanceTransactionCreateParams parameters, @@ -45,26 +61,26 @@ Task Create( /// /// ## The customer balance /// - /// The customer balance is an amount in the customer's currency, which - /// Orb automatically applies to subsequent invoices. This balance can be adjusted + /// The customer balance is an amount in the customer's currency, which Orb + /// automatically applies to subsequent invoices. This balance can be adjusted /// manually via Orb's webapp on the customer details page. You can use this balance - /// to provide a fixed mid-period credit to the customer. Commonly, this is done - /// due to system downtime/SLA violation, or an adhoc adjustment discussed with - /// the customer. + /// to provide a fixed mid-period credit to the customer. Commonly, this is done due + /// to system downtime/SLA violation, or an adhoc adjustment discussed with the + /// customer. /// /// If the balance is a positive value at the time of invoicing, it represents - /// that the customer has credit that should be used to offset the amount due - /// on the next issued invoice. In this case, Orb will automatically reduce the - /// next invoice by the balance amount, and roll over any remaining balance if - /// the invoice is fully discounted. + /// that the customer has credit that should be used to offset the amount due on the + /// next issued invoice. In this case, Orb will automatically reduce the next + /// invoice by the balance amount, and roll over any remaining balance if the + /// invoice is fully discounted. /// /// If the balance is a negative value at the time of invoicing, Orb will /// increase the invoice's amount due with a positive adjustment, and reset the /// balance to 0. /// /// This endpoint retrieves all customer balance transactions in reverse - /// chronological order for a single customer, providing a complete audit trail - /// of all adjustments and invoice applications. + /// chronological order for a single customer, providing a complete audit trail of + /// all adjustments and invoice applications. /// Task List( BalanceTransactionListParams parameters, @@ -95,7 +111,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `post /customers/{customer_id}/balance_transactions`, but is otherwise the + /// Returns a raw HTTP response for post /customers/{customer_id}/balance_transactions, but is otherwise the /// same as . /// Task> Create( @@ -111,7 +127,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/balance_transactions`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/balance_transactions, but is otherwise the /// same as . /// Task> List( diff --git a/src/Orb/Services/Customers/ICostService.cs b/src/Orb/Services/Customers/ICostService.cs index 6aeaf9461..1ea83c652 100644 --- a/src/Orb/Services/Customers/ICostService.cs +++ b/src/Orb/Services/Customers/ICostService.cs @@ -7,9 +7,25 @@ namespace Orb.Services.Customers; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// A customer is a buyer of your products, and the other party to the billing relationship. +/// +/// In Orb, customers are assigned system generated identifiers automatically, +/// but it's often desirable to have these match existing identifiers in your system. +/// To avoid having to denormalize Orb ID information, you can pass in an `external_customer_id` +/// with your own identifier. See [Customer ID Aliases](/events-and-metrics/customer-aliases) +/// for further information about how these aliases work in Orb. +/// +/// In addition to having an identifier in your system, a customer may exist +/// in a payment provider solution like Stripe. Use the `payment_provider_id` and +/// the `payment_provider` enum field to express this mapping. +/// +/// A customer also has a timezone (from the standard [IANA timezone database](https://www.iana.org/time-zones)), +/// which defaults to your account's timezone. See [Timezone localization](/essentials/timezones) +/// for information on what this timezone parameter influences within Orb. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface ICostService { @@ -27,103 +43,107 @@ public interface ICostService ICostService WithOptions(Func modifier); /// - /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs - /// in Orb, calculated by applying pricing information to the underlying usage - /// (see the [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) - /// to fetch usage per metric, in usage units rather than a currency). - /// - /// This endpoint can be leveraged for internal tooling and to provide a - /// more transparent billing experience for your end users: - /// - /// 1. Understand the cost breakdown per line item historically and in real-time - /// for the current billing period. 2. Provide customer visibility into how different - /// services are contributing to the overall invoice with a per-day timeseries - /// (as compared to the [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) - /// resource, which represents a snapshot for the current period). 3. Assess - /// how minimums and discounts affect your customers by teasing apart costs directly - /// as a result of usage, as opposed to minimums and discounts at the plan - /// and price level. 4. Gain insight into key customer health metrics, such as - /// the percent utilization of the minimum committed spend. + /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs in + /// Orb, calculated by applying pricing information to the underlying usage (see the + /// [subscription usage + /// endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch usage + /// per metric, in usage units rather than a currency). + /// + /// This endpoint can be leveraged for internal tooling and to provide a more + /// transparent billing experience for your end users: + /// + /// 1. Understand the cost breakdown per line item historically and in + /// real-time for the current billing period. 2. Provide customer visibility into + /// how different services are contributing to the overall invoice with a per-day + /// timeseries (as compared to the [upcoming + /// invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which + /// represents a snapshot for the current period). 3. Assess how minimums and + /// discounts affect your customers by teasing apart costs directly as a result of + /// usage, as opposed to minimums and discounts at the plan and price level. 4. + /// Gain insight into key customer health metrics, such as the percent utilization + /// of the minimum committed spend. /// /// ## Fetching subscriptions By default, this endpoint fetches the currently /// active subscription for the customer, and returns cost information for the - /// subscription's current billing period, broken down by each participating - /// price. If there are no currently active subscriptions, this will instead default - /// to the most recently active subscription or return an empty series if none - /// are found. For example, if your plan charges for compute hours, job runs, - /// and data syncs, then this endpoint would provide a daily breakdown of your - /// customer's cost for each of those axes. - /// - /// If timeframe bounds are specified, Orb fetches all subscriptions that - /// were active in that timeframe. If two subscriptions overlap on a single day, - /// costs from each price will be summed, and prices for both subscriptions will - /// be included in the breakdown. - /// - /// ## Prepaid plans For plans that include prices which deduct credits - /// rather than accrue in-arrears charges in a billable currency, this endpoint - /// will return the total deduction amount, in credits, for the specified timeframe. + /// subscription's current billing period, broken down by each participating price. + /// If there are no currently active subscriptions, this will instead default to the + /// most recently active subscription or return an empty series if none are found. + /// For example, if your plan charges for compute hours, job runs, and data syncs, + /// then this endpoint would provide a daily breakdown of your customer's cost for + /// each of those axes. + /// + /// If timeframe bounds are specified, Orb fetches all subscriptions that were + /// active in that timeframe. If two subscriptions overlap on a single day, costs + /// from each price will be summed, and prices for both subscriptions will be + /// included in the breakdown. + /// + /// ## Prepaid plans For plans that include prices which deduct credits rather + /// than accrue in-arrears charges in a billable currency, this endpoint will return + /// the total deduction amount, in credits, for the specified timeframe. /// /// ## Cumulative subtotals and totals Since the subtotal and total must /// factor in any billing-period level discounts and minimums, it's most meaningful - /// to consider costs relative to the start of the subscription's billing period. - /// As a result, by default this endpoint returns cumulative totals since the - /// beginning of the billing period. In particular, the `timeframe_start` of - /// a returned timeframe window is *always* the beginning of the billing period - /// and `timeframe_end` is incremented one day at a time to build the result. + /// to consider costs relative to the start of the subscription's billing period. As + /// a result, by default this endpoint returns cumulative totals since the beginning + /// of the billing period. In particular, the `timeframe_start` of a returned + /// timeframe window is *always* the beginning of the billing period and + /// `timeframe_end` is incremented one day at a time to build the result. /// /// A customer that uses a few API calls a day but has a minimum commitment /// might exhibit the following pattern for their subtotal and total in the first - /// few days of the month. Here, we assume that each API call is \$2.50, the customer's - /// plan has a monthly minimum of \$50 for this price, and that the subscription's - /// billing period bounds are aligned to the first of the month: + /// few days of the month. Here, we assume that each API call is \$2.50, the + /// customer's plan has a monthly minimum of \$50 for this price, and that the + /// subscription's billing period bounds are aligned to the first of the month: /// /// | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total - /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- - /// |----------- | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 - /// | 2023-02-03 | 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | - /// \$50.00 | \$50.00 | | 2023-02-01 | 2023-02-05 | 28 | \$70.00 | \$70.00 | | - /// 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | + /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- |----------- + /// | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 | 2023-02-03 | + /// 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | \$50.00 | \$50.00 | | 2023-02-01 + /// | 2023-02-05 | 28 | \$70.00 | \$70.00 | | 2023-02-01 | 2023-02-06 | 36 | \$90.00 + /// | \$90.00 | /// /// ### Periodic values When the query parameter `view_mode=periodic` is /// specified, Orb will return an incremental day-by-day view of costs. In this - /// case, there will always be a one-day difference between `timeframe_start` - /// and `timeframe_end` for the timeframes returned. This is a transform on top - /// of the cumulative costs, calculated by taking the difference of each timeframe - /// with the last. Note that in the above example, the `Total` value would be - /// 0 for the second two data points, since the minimum commitment has not yet - /// been hit and each day is not contributing anything to the total cost. - /// - /// ## Timeframe bounds For an active subscription, both timeframes should - /// be specified in the request. If a subscription starts or ends within the timeframe, - /// the response will only include windows where the subscription is active. If - /// a subscription has ended, no timeframe bounds need to be specified and the - /// response will default to the billing period when the subscription was last active. + /// case, there will always be a one-day difference between `timeframe_start` and + /// `timeframe_end` for the timeframes returned. This is a transform on top of the + /// cumulative costs, calculated by taking the difference of each timeframe with the + /// last. Note that in the above example, the `Total` value would be 0 for the + /// second two data points, since the minimum commitment has not yet been hit and + /// each day is not contributing anything to the total cost. + /// + /// ## Timeframe bounds For an active subscription, both timeframes should be + /// specified in the request. If a subscription starts or ends within the timeframe, + /// the response will only include windows where the subscription is active. If a + /// subscription has ended, no timeframe bounds need to be specified and the + /// response will default to the billing period when the subscription was last + /// active. /// /// As noted above, `timeframe_start` for a given cumulative datapoint is /// always the beginning of the billing period, and `timeframe_end` is incremented - /// one day at a time to construct the response. When a timeframe is passed in - /// that is not aligned to the current subscription's billing period, the response - /// will contain cumulative totals from multiple billing periods. - /// - /// Suppose the queried customer has a subscription aligned to the 15th - /// of every month. If this endpoint is queried with the date range `2023-06-01` - /// - `2023-07-01`, the first data point will represent about half a billing - /// period's worth of costs, accounting for accruals from the start of the billing - /// period and inclusive of the first day of the timeframe (`timeframe_start - /// = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - /// - /// | datapoint index | timeframe_start | timeframe_end | | ----------- - /// | -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 - /// | 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 - /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | 2023-06-15 - /// | 2023-07-01 | - /// - /// You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - /// - /// ### Matrix prices When a price uses matrix pricing, it's important to - /// view costs grouped by those matrix dimensions. Orb will return `price_groups` - /// with the `grouping_key` and `secondary_grouping_key` based on the matrix - /// price definition, for each `grouping_value` and `secondary_grouping_value` available. + /// one day at a time to construct the response. When a timeframe is passed in that + /// is not aligned to the current subscription's billing period, the response will + /// contain cumulative totals from multiple billing periods. + /// + /// Suppose the queried customer has a subscription aligned to the 15th of + /// every month. If this endpoint is queried with the date range `2023-06-01` - + /// `2023-07-01`, the first data point will represent about half a billing period's + /// worth of costs, accounting for accruals from the start of the billing period and + /// inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + /// 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + /// + /// | datapoint index | timeframe_start | timeframe_end | | ----------- | + /// -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 | + /// 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 + /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | + /// 2023-06-15 | 2023-07-01 | + /// + /// You can see this sliced timeframe visualized + /// [here](https://i.imgur.com/TXhYgme.png). + /// + /// ### Matrix prices When a price uses matrix pricing, it's important to view + /// costs grouped by those matrix dimensions. Orb will return `price_groups` with + /// the `grouping_key` and `secondary_grouping_key` based on the matrix price + /// definition, for each `grouping_value` and `secondary_grouping_value` available. /// Task List( CostListParams parameters, @@ -138,103 +158,107 @@ Task List( ); /// - /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs - /// in Orb, calculated by applying pricing information to the underlying usage - /// (see the [subscription usage endpoint](/api-reference/subscription/fetch-subscription-usage) - /// to fetch usage per metric, in usage units rather than a currency). - /// - /// This endpoint can be leveraged for internal tooling and to provide a - /// more transparent billing experience for your end users: - /// - /// 1. Understand the cost breakdown per line item historically and in real-time - /// for the current billing period. 2. Provide customer visibility into how different - /// services are contributing to the overall invoice with a per-day timeseries - /// (as compared to the [upcoming invoice](/api-reference/invoice/fetch-upcoming-invoice) - /// resource, which represents a snapshot for the current period). 3. Assess - /// how minimums and discounts affect your customers by teasing apart costs directly - /// as a result of usage, as opposed to minimums and discounts at the plan - /// and price level. 4. Gain insight into key customer health metrics, such as - /// the percent utilization of the minimum committed spend. + /// This endpoint is used to fetch a day-by-day snapshot of a customer's costs in + /// Orb, calculated by applying pricing information to the underlying usage (see the + /// [subscription usage + /// endpoint](/api-reference/subscription/fetch-subscription-usage) to fetch usage + /// per metric, in usage units rather than a currency). + /// + /// This endpoint can be leveraged for internal tooling and to provide a more + /// transparent billing experience for your end users: + /// + /// 1. Understand the cost breakdown per line item historically and in + /// real-time for the current billing period. 2. Provide customer visibility into + /// how different services are contributing to the overall invoice with a per-day + /// timeseries (as compared to the [upcoming + /// invoice](/api-reference/invoice/fetch-upcoming-invoice) resource, which + /// represents a snapshot for the current period). 3. Assess how minimums and + /// discounts affect your customers by teasing apart costs directly as a result of + /// usage, as opposed to minimums and discounts at the plan and price level. 4. + /// Gain insight into key customer health metrics, such as the percent utilization + /// of the minimum committed spend. /// /// ## Fetching subscriptions By default, this endpoint fetches the currently /// active subscription for the customer, and returns cost information for the - /// subscription's current billing period, broken down by each participating - /// price. If there are no currently active subscriptions, this will instead default - /// to the most recently active subscription or return an empty series if none - /// are found. For example, if your plan charges for compute hours, job runs, - /// and data syncs, then this endpoint would provide a daily breakdown of your - /// customer's cost for each of those axes. - /// - /// If timeframe bounds are specified, Orb fetches all subscriptions that - /// were active in that timeframe. If two subscriptions overlap on a single day, - /// costs from each price will be summed, and prices for both subscriptions will - /// be included in the breakdown. - /// - /// ## Prepaid plans For plans that include prices which deduct credits - /// rather than accrue in-arrears charges in a billable currency, this endpoint - /// will return the total deduction amount, in credits, for the specified timeframe. + /// subscription's current billing period, broken down by each participating price. + /// If there are no currently active subscriptions, this will instead default to the + /// most recently active subscription or return an empty series if none are found. + /// For example, if your plan charges for compute hours, job runs, and data syncs, + /// then this endpoint would provide a daily breakdown of your customer's cost for + /// each of those axes. + /// + /// If timeframe bounds are specified, Orb fetches all subscriptions that were + /// active in that timeframe. If two subscriptions overlap on a single day, costs + /// from each price will be summed, and prices for both subscriptions will be + /// included in the breakdown. + /// + /// ## Prepaid plans For plans that include prices which deduct credits rather + /// than accrue in-arrears charges in a billable currency, this endpoint will return + /// the total deduction amount, in credits, for the specified timeframe. /// /// ## Cumulative subtotals and totals Since the subtotal and total must /// factor in any billing-period level discounts and minimums, it's most meaningful - /// to consider costs relative to the start of the subscription's billing period. - /// As a result, by default this endpoint returns cumulative totals since the - /// beginning of the billing period. In particular, the `timeframe_start` of - /// a returned timeframe window is *always* the beginning of the billing period - /// and `timeframe_end` is incremented one day at a time to build the result. + /// to consider costs relative to the start of the subscription's billing period. As + /// a result, by default this endpoint returns cumulative totals since the beginning + /// of the billing period. In particular, the `timeframe_start` of a returned + /// timeframe window is *always* the beginning of the billing period and + /// `timeframe_end` is incremented one day at a time to build the result. /// /// A customer that uses a few API calls a day but has a minimum commitment /// might exhibit the following pattern for their subtotal and total in the first - /// few days of the month. Here, we assume that each API call is \$2.50, the customer's - /// plan has a monthly minimum of \$50 for this price, and that the subscription's - /// billing period bounds are aligned to the first of the month: + /// few days of the month. Here, we assume that each API call is \$2.50, the + /// customer's plan has a monthly minimum of \$50 for this price, and that the + /// subscription's billing period bounds are aligned to the first of the month: /// /// | timeframe_start | timeframe_end | Cumulative usage | Subtotal | Total - /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- - /// |----------- | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 - /// | 2023-02-03 | 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | - /// \$50.00 | \$50.00 | | 2023-02-01 | 2023-02-05 | 28 | \$70.00 | \$70.00 | | - /// 2023-02-01 | 2023-02-06 | 36 | \$90.00 | \$90.00 | + /// (incl. commitment) | | -----------| ----------- | ----------- | ----------- |----------- + /// | | 2023-02-01 | 2023-02-02 | 9 | \$22.50 | \$50.00 | | 2023-02-01 | 2023-02-03 | + /// 19 | \$47.50 | \$50.00 | | 2023-02-01 | 2023-02-04 | 20 | \$50.00 | \$50.00 | | 2023-02-01 + /// | 2023-02-05 | 28 | \$70.00 | \$70.00 | | 2023-02-01 | 2023-02-06 | 36 | \$90.00 + /// | \$90.00 | /// /// ### Periodic values When the query parameter `view_mode=periodic` is /// specified, Orb will return an incremental day-by-day view of costs. In this - /// case, there will always be a one-day difference between `timeframe_start` - /// and `timeframe_end` for the timeframes returned. This is a transform on top - /// of the cumulative costs, calculated by taking the difference of each timeframe - /// with the last. Note that in the above example, the `Total` value would be - /// 0 for the second two data points, since the minimum commitment has not yet - /// been hit and each day is not contributing anything to the total cost. - /// - /// ## Timeframe bounds For an active subscription, both timeframes should - /// be specified in the request. If a subscription starts or ends within the timeframe, - /// the response will only include windows where the subscription is active. If - /// a subscription has ended, no timeframe bounds need to be specified and the - /// response will default to the billing period when the subscription was last active. + /// case, there will always be a one-day difference between `timeframe_start` and + /// `timeframe_end` for the timeframes returned. This is a transform on top of the + /// cumulative costs, calculated by taking the difference of each timeframe with the + /// last. Note that in the above example, the `Total` value would be 0 for the + /// second two data points, since the minimum commitment has not yet been hit and + /// each day is not contributing anything to the total cost. + /// + /// ## Timeframe bounds For an active subscription, both timeframes should be + /// specified in the request. If a subscription starts or ends within the timeframe, + /// the response will only include windows where the subscription is active. If a + /// subscription has ended, no timeframe bounds need to be specified and the + /// response will default to the billing period when the subscription was last + /// active. /// /// As noted above, `timeframe_start` for a given cumulative datapoint is /// always the beginning of the billing period, and `timeframe_end` is incremented - /// one day at a time to construct the response. When a timeframe is passed in - /// that is not aligned to the current subscription's billing period, the response - /// will contain cumulative totals from multiple billing periods. - /// - /// Suppose the queried customer has a subscription aligned to the 15th - /// of every month. If this endpoint is queried with the date range `2023-06-01` - /// - `2023-07-01`, the first data point will represent about half a billing - /// period's worth of costs, accounting for accruals from the start of the billing - /// period and inclusive of the first day of the timeframe (`timeframe_start - /// = 2023-05-15 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) - /// - /// | datapoint index | timeframe_start | timeframe_end | | ----------- - /// | -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 - /// | 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 - /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | 2023-06-15 - /// | 2023-07-01 | - /// - /// You can see this sliced timeframe visualized [here](https://i.imgur.com/TXhYgme.png). - /// - /// ### Matrix prices When a price uses matrix pricing, it's important to - /// view costs grouped by those matrix dimensions. Orb will return `price_groups` - /// with the `grouping_key` and `secondary_grouping_key` based on the matrix - /// price definition, for each `grouping_value` and `secondary_grouping_value` available. + /// one day at a time to construct the response. When a timeframe is passed in that + /// is not aligned to the current subscription's billing period, the response will + /// contain cumulative totals from multiple billing periods. + /// + /// Suppose the queried customer has a subscription aligned to the 15th of + /// every month. If this endpoint is queried with the date range `2023-06-01` - + /// `2023-07-01`, the first data point will represent about half a billing period's + /// worth of costs, accounting for accruals from the start of the billing period and + /// inclusive of the first day of the timeframe (`timeframe_start = 2023-05-15 + /// 00:00:00`, `timeframe_end = 2023-06-02 00:00:00`) + /// + /// | datapoint index | timeframe_start | timeframe_end | | ----------- | + /// -----------| ----------- | | 0 | 2023-05-15 | 2023-06-02 | | 1 | 2023-05-15 | + /// 2023-06-03 | | 2 | ... | ... | | 3 | 2023-05-15 | 2023-06-14 | | 4 | 2023-06-15 + /// | 2023-06-16 | | 5 | 2023-06-15 | 2023-06-17 | | 6 | ... | ... | | 7 | + /// 2023-06-15 | 2023-07-01 | + /// + /// You can see this sliced timeframe visualized + /// [here](https://i.imgur.com/TXhYgme.png). + /// + /// ### Matrix prices When a price uses matrix pricing, it's important to view + /// costs grouped by those matrix dimensions. Orb will return `price_groups` with + /// the `grouping_key` and `secondary_grouping_key` based on the matrix price + /// definition, for each `grouping_value` and `secondary_grouping_value` available. /// Task ListByExternalID( CostListByExternalIDParams parameters, @@ -263,7 +287,7 @@ public interface ICostServiceWithRawResponse ICostServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/costs`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/costs, but is otherwise the /// same as . /// Task> List( @@ -279,7 +303,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/costs`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/costs, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/Customers/ICreditService.cs b/src/Orb/Services/Customers/ICreditService.cs index 71044e6ab..d7c402202 100644 --- a/src/Orb/Services/Customers/ICreditService.cs +++ b/src/Orb/Services/Customers/ICreditService.cs @@ -8,9 +8,12 @@ namespace Orb.Services.Customers; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Credit Ledger Entry resource](/product-catalog/prepurchase) models prepaid +/// credits within Orb. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface ICreditService { @@ -37,8 +40,13 @@ public interface ICreditService /// If `include_all_blocks` is set to `true`, all credit blocks (including /// expired and depleted blocks) will be included in the response. /// - /// Note that `currency` defaults to credits if not specified. To use a - /// real world currency, set `currency` to an ISO 4217 string. + /// Note that `currency` defaults to credits if not specified. To use a real + /// world currency, set `currency` to an ISO 4217 string. + /// + /// Results can be filtered by the block's `effective_date` using the + /// `effective_date[gte]`, `effective_date[gt]`, `effective_date[lt]`, and + /// `effective_date[lte]` query parameters. This filters on when the credit block + /// becomes effective, which may differ from creation time for backdated credits. /// Task List( CreditListParams parameters, @@ -58,8 +66,13 @@ Task List( /// If `include_all_blocks` is set to `true`, all credit blocks (including /// expired and depleted blocks) will be included in the response. /// - /// Note that `currency` defaults to credits if not specified. To use a - /// real world currency, set `currency` to an ISO 4217 string. + /// Note that `currency` defaults to credits if not specified. To use a real + /// world currency, set `currency` to an ISO 4217 string. + /// + /// Results can be filtered by the block's `effective_date` using the + /// `effective_date[gte]`, `effective_date[gt]`, `effective_date[lt]`, and + /// `effective_date[lte]` query parameters. This filters on when the credit block + /// becomes effective, which may differ from creation time for backdated credits. /// Task ListByExternalID( CreditListByExternalIDParams parameters, @@ -92,7 +105,7 @@ public interface ICreditServiceWithRawResponse ITopUpServiceWithRawResponse TopUps { get; } /// - /// Returns a raw HTTP response for `get /customers/{customer_id}/credits`, but is otherwise the + /// Returns a raw HTTP response for get /customers/{customer_id}/credits, but is otherwise the /// same as . /// Task> List( @@ -108,7 +121,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /customers/external_customer_id/{external_customer_id}/credits`, but is otherwise the + /// Returns a raw HTTP response for get /customers/external_customer_id/{external_customer_id}/credits, but is otherwise the /// same as . /// Task> ListByExternalID( diff --git a/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs b/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs index a62abd3a3..e09c7a890 100644 --- a/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs +++ b/src/Orb/Services/DimensionalPriceGroups/IExternalDimensionalPriceGroupIDService.cs @@ -46,8 +46,8 @@ Task Retrieve( /// /// This endpoint can be used to update the `external_dimensional_price_group_id` - /// and `metadata` of an existing dimensional price group. Other fields on a dimensional - /// price group are currently immutable. + /// and `metadata` of an existing dimensional price group. Other fields on a + /// dimensional price group are currently immutable. /// Task Update( ExternalDimensionalPriceGroupIDUpdateParams parameters, @@ -78,7 +78,7 @@ Func modifier ); /// - /// Returns a raw HTTP response for `get /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for get /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -94,7 +94,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `put /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}`, but is otherwise the + /// Returns a raw HTTP response for put /dimensional_price_groups/external_dimensional_price_group_id/{external_dimensional_price_group_id}, but is otherwise the /// same as . /// Task> Update( diff --git a/src/Orb/Services/Events/IBackfillService.cs b/src/Orb/Services/Events/IBackfillService.cs index 5cbafef73..e7abc6961 100644 --- a/src/Orb/Services/Events/IBackfillService.cs +++ b/src/Orb/Services/Events/IBackfillService.cs @@ -7,9 +7,13 @@ namespace Orb.Services.Events; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Event](/core-concepts#event) resource represents a usage event that has been +/// created for a customer. Events are the core of Orb's usage-based billing model, +/// and are used to calculate the usage charges for a given billing period. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IBackfillService { @@ -27,40 +31,42 @@ public interface IBackfillService IBackfillService WithOptions(Func modifier); /// - /// Creating the backfill enables adding or replacing past events, even those - /// that are older than the ingestion grace period. Performing a backfill in Orb - /// involves 3 steps: + /// Creating the backfill enables adding or replacing past events, even those that + /// are older than the ingestion grace period. Performing a backfill in Orb involves + /// 3 steps: /// - /// 1. Create the backfill, specifying its parameters. 2. [Ingest](ingest) - /// usage events, referencing the backfill (query parameter `backfill_id`). 3. - /// [Close](close-backfill) the backfill, propagating the update in past usage - /// throughout Orb. + /// 1. Create the backfill, specifying its parameters. 2. + /// [Ingest](/api-reference/event/ingest-events) usage events, referencing the + /// backfill (query parameter `backfill_id`). 3. [Close](close-backfill) the + /// backfill, propagating the update in past usage throughout Orb. /// - /// Changes from a backfill are not reflected until the backfill is closed, - /// so you won’t need to worry about your customers seeing partially updated - /// usage data. Backfills are also reversible, so you’ll be able to revert a backfill - /// if you’ve made a mistake. + /// Changes from a backfill are not reflected until the backfill is closed, so + /// you won’t need to worry about your customers seeing partially updated usage + /// data. Backfills are also reversible, so you’ll be able to revert a backfill if + /// you’ve made a mistake. /// - /// This endpoint will return a backfill object, which contains an `id`. - /// That `id` can then be used as the `backfill_id` query parameter to the event + /// This endpoint will return a backfill object, which contains an `id`. That + /// `id` can then be used as the `backfill_id` query parameter to the event /// ingestion endpoint to associate ingested events with this backfill. The effects /// (e.g. updated usage graphs) of this backfill will not take place until the /// backfill is closed. /// - /// If the `replace_existing_events` is `true`, existing events in the backfill's - /// timeframe will be replaced with the newly ingested events associated with - /// the backfill. If `false`, newly ingested events will be added to the existing events. + /// If the `replace_existing_events` is `true`, existing events in the + /// backfill's timeframe will be replaced with the newly ingested events associated + /// with the backfill. If `false`, newly ingested events will be added to the + /// existing events. /// /// If a `customer_id` or `external_customer_id` is specified, the backfill /// will only affect events for that customer. If neither is specified, the backfill /// will affect all customers. /// /// When `replace_existing_events` is `true`, this indicates that existing - /// events in the timeframe should no longer be counted towards invoiced usage. - /// In this scenario, the parameter `deprecation_filter` can be optionally added - /// which enables filtering using [computed properties](/extensibility/advanced-metrics#computed-properties). - /// The expressiveness of computed properties allows you to deprecate existing - /// events based on both a period of time and specific property values. + /// events in the timeframe should no longer be counted towards invoiced usage. In + /// this scenario, the parameter `deprecation_filter` can be optionally added which + /// enables filtering using [computed + /// properties](/extensibility/advanced-metrics#computed-properties). The + /// expressiveness of computed properties allows you to deprecate existing events + /// based on both a period of time and specific property values. /// /// You may not have multiple backfills in a pending or pending_revert state /// with overlapping timeframes. @@ -74,9 +80,9 @@ Task Create( /// This endpoint returns a list of all backfills in a list format. /// /// The list of backfills is ordered starting from the most recently created - /// backfill. The response also includes [`pagination_metadata`](/api-reference/pagination), - /// which lets the caller retrieve the next page of results if they exist. More - /// information about pagination can be found in the [Pagination-metadata schema](pagination). + /// backfill. The response also includes + /// [`pagination_metadata`](/api-reference/pagination), which lets the caller + /// retrieve the next page of results if they exist. /// Task List( BackfillListParams? parameters = null, @@ -118,12 +124,12 @@ Task Fetch( /// /// Reverting a backfill undoes all the effects of closing the backfill. If the - /// backfill is reflected, the status will transition to `pending_revert` while - /// the effects of the backfill are undone. Once all effects are undone, the - /// backfill will transition to `reverted`. + /// backfill is reflected, the status will transition to `pending_revert` while the + /// effects of the backfill are undone. Once all effects are undone, the backfill + /// will transition to `reverted`. /// - /// If a backfill is reverted before its closed, no usage will be updated - /// as a result of the backfill and it will immediately transition to `reverted`. + /// If a backfill is reverted before its closed, no usage will be updated as a + /// result of the backfill and it will immediately transition to `reverted`. /// Task Revert( BackfillRevertParams parameters, @@ -152,7 +158,7 @@ public interface IBackfillServiceWithRawResponse IBackfillServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /events/backfills`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills, but is otherwise the /// same as . /// Task> Create( @@ -161,7 +167,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /events/backfills`, but is otherwise the + /// Returns a raw HTTP response for get /events/backfills, but is otherwise the /// same as . /// Task> List( @@ -170,7 +176,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /events/backfills/{backfill_id}/close`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills/{backfill_id}/close, but is otherwise the /// same as . /// Task> Close( @@ -186,7 +192,7 @@ Task> Close( ); /// - /// Returns a raw HTTP response for `get /events/backfills/{backfill_id}`, but is otherwise the + /// Returns a raw HTTP response for get /events/backfills/{backfill_id}, but is otherwise the /// same as . /// Task> Fetch( @@ -202,7 +208,7 @@ Task> Fetch( ); /// - /// Returns a raw HTTP response for `post /events/backfills/{backfill_id}/revert`, but is otherwise the + /// Returns a raw HTTP response for post /events/backfills/{backfill_id}/revert, but is otherwise the /// same as . /// Task> Revert( diff --git a/src/Orb/Services/Events/IVolumeService.cs b/src/Orb/Services/Events/IVolumeService.cs index 4f42b7a76..2b06ce66c 100644 --- a/src/Orb/Services/Events/IVolumeService.cs +++ b/src/Orb/Services/Events/IVolumeService.cs @@ -7,9 +7,13 @@ namespace Orb.Services.Events; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Event](/core-concepts#event) resource represents a usage event that has been +/// created for a customer. Events are the core of Orb's usage-based billing model, +/// and are used to calculate the usage charges for a given billing period. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IVolumeService { @@ -27,17 +31,19 @@ public interface IVolumeService IVolumeService WithOptions(Func modifier); /// - /// This endpoint returns the event volume for an account in a [paginated list format](/api-reference/pagination). + /// This endpoint returns the event volume for an account in a [paginated list + /// format](/api-reference/pagination). /// - /// The event volume is aggregated by the hour and the [timestamp](/api-reference/event/ingest-events) - /// field is used to determine which hour an event is associated with. Note, - /// this means that late-arriving events increment the volume count for the hour - /// window the timestamp is in, not the latest hour window. + /// The event volume is aggregated by the hour and the + /// [timestamp](/api-reference/event/ingest-events) field is used to determine which + /// hour an event is associated with. Note, this means that late-arriving events + /// increment the volume count for the hour window the timestamp is in, not the + /// latest hour window. /// - /// Each item in the response contains the count of events aggregated by - /// the hour where the start and end time are hour-aligned and in UTC. When a - /// specific timestamp is passed in for either start or end time, the response - /// includes the hours the timestamp falls in. + /// Each item in the response contains the count of events aggregated by the + /// hour where the start and end time are hour-aligned and in UTC. When a specific + /// timestamp is passed in for either start or end time, the response includes the + /// hours the timestamp falls in. /// Task List( VolumeListParams parameters, @@ -59,7 +65,7 @@ public interface IVolumeServiceWithRawResponse IVolumeServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /events/volume`, but is otherwise the + /// Returns a raw HTTP response for get /events/volume, but is otherwise the /// same as . /// Task> List( diff --git a/src/Orb/Services/IAlertService.cs b/src/Orb/Services/IAlertService.cs index fe2b3ae13..210b9bf2f 100644 --- a/src/Orb/Services/IAlertService.cs +++ b/src/Orb/Services/IAlertService.cs @@ -7,9 +7,14 @@ namespace Orb.Services; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// [Alerts within Orb](/product-catalog/configuring-alerts) monitor spending, usage, +/// or credit balance and trigger webhooks when a threshold is exceeded. +/// +/// Alerts created through the API can be scoped to either customers or subscriptions. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IAlertService { @@ -56,14 +61,15 @@ Task Update( /// /// This endpoint returns a list of alerts within Orb. /// - /// The request must specify one of `customer_id`, `external_customer_id`, - /// or `subscription_id`. + /// The request must specify one of `customer_id`, `external_customer_id`, or + /// `subscription_id`. /// /// If querying by subscription_id, the endpoint will return the subscription /// level alerts as well as the plan level alerts associated with the subscription. /// /// The list of alerts is ordered starting from the most recently created - /// alert. This endpoint follows Orb's [standardized pagination format](/api-reference/pagination). + /// alert. This endpoint follows Orb's [standardized pagination + /// format](/api-reference/pagination). /// Task List( AlertListParams? parameters = null, @@ -71,13 +77,14 @@ Task List( ); /// - /// This endpoint creates a new alert to monitor a customer's credit balance. - /// There are three types of alerts that can be scoped to customers: `credit_balance_depleted`, - /// `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have - /// a maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). - /// `credit_balance_dropped` alerts require a list of thresholds to be provided - /// while `credit_balance_depleted` and `credit_balance_recovered` alerts do - /// not require thresholds. + /// This endpoint creates a new alert to monitor a customer's credit balance. There + /// are three types of alerts that can be scoped to customers: + /// `credit_balance_depleted`, `credit_balance_dropped`, and + /// `credit_balance_recovered`. Customers can have a maximum of one of each type of + /// alert per [credit balance currency](/product-catalog/prepurchase). `credit_balance_dropped` + /// alerts require a list of thresholds to be provided while `credit_balance_depleted` + /// + /// and `credit_balance_recovered` alerts do not require thresholds. /// Task CreateForCustomer( AlertCreateForCustomerParams parameters, @@ -92,13 +99,14 @@ Task CreateForCustomer( ); /// - /// This endpoint creates a new alert to monitor a customer's credit balance. - /// There are three types of alerts that can be scoped to customers: `credit_balance_depleted`, - /// `credit_balance_dropped`, and `credit_balance_recovered`. Customers can have - /// a maximum of one of each type of alert per [credit balance currency](/product-catalog/prepurchase). - /// `credit_balance_dropped` alerts require a list of thresholds to be provided - /// while `credit_balance_depleted` and `credit_balance_recovered` alerts do - /// not require thresholds. + /// This endpoint creates a new alert to monitor a customer's credit balance. There + /// are three types of alerts that can be scoped to customers: + /// `credit_balance_depleted`, `credit_balance_dropped`, and + /// `credit_balance_recovered`. Customers can have a maximum of one of each type of + /// alert per [credit balance currency](/product-catalog/prepurchase). `credit_balance_dropped` + /// alerts require a list of thresholds to be provided while `credit_balance_depleted` + /// + /// and `credit_balance_recovered` alerts do not require thresholds. /// Task CreateForExternalCustomer( AlertCreateForExternalCustomerParams parameters, @@ -115,15 +123,15 @@ Task CreateForExternalCustomer( /// /// This endpoint is used to create alerts at the subscription level. /// - /// Subscription level alerts can be one of two types: `usage_exceeded` - /// or `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric - /// and is triggered when the usage of that metric exceeds predefined thresholds - /// during the current billing cycle. A `cost_exceeded` alert is triggered when - /// the total amount due during the current billing cycle surpasses predefined - /// thresholds. `cost_exceeded` alerts do not include burndown of pre-purchase - /// credits. Each subscription can have one `cost_exceeded` alert and one `usage_exceeded` - /// alert per metric that is a part of the subscription. Alerts are triggered - /// based on usage or cost conditions met during the current billing cycle. + /// Subscription level alerts can be one of two types: `usage_exceeded` or + /// `cost_exceeded`. A `usage_exceeded` alert is scoped to a particular metric and + /// is triggered when the usage of that metric exceeds predefined thresholds during + /// the current billing cycle. A `cost_exceeded` alert is triggered when the total + /// amount due during the current billing cycle surpasses predefined thresholds. + /// `cost_exceeded` alerts do not include burndown of pre-purchase credits. Each + /// subscription can have one `cost_exceeded` alert and one `usage_exceeded` alert + /// per metric that is a part of the subscription. Alerts are triggered based on + /// usage or cost conditions met during the current billing cycle. /// Task CreateForSubscription( AlertCreateForSubscriptionParams parameters, @@ -138,9 +146,9 @@ Task CreateForSubscription( ); /// - /// This endpoint allows you to disable an alert. To disable a plan-level alert - /// for a specific subscription, you must include the `subscription_id`. The `subscription_id` - /// is not required for customer or subscription level alerts. + /// This endpoint allows you to disable an alert. To disable a plan-level alert for + /// a specific subscription, you must include the `subscription_id`. The + /// `subscription_id` is not required for customer or subscription level alerts. /// Task Disable( AlertDisableParams parameters, @@ -155,9 +163,9 @@ Task Disable( ); /// - /// This endpoint allows you to enable an alert. To enable a plan-level alert - /// for a specific subscription, you must include the `subscription_id`. The `subscription_id` - /// is not required for customer or subscription level alerts. + /// This endpoint allows you to enable an alert. To enable a plan-level alert for a + /// specific subscription, you must include the `subscription_id`. The + /// `subscription_id` is not required for customer or subscription level alerts. /// Task Enable(AlertEnableParams parameters, CancellationToken cancellationToken = default); @@ -183,7 +191,7 @@ public interface IAlertServiceWithRawResponse IAlertServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `get /alerts/{alert_id}`, but is otherwise the + /// Returns a raw HTTP response for get /alerts/{alert_id}, but is otherwise the /// same as . /// Task> Retrieve( @@ -199,7 +207,7 @@ Task> Retrieve( ); /// - /// Returns a raw HTTP response for `put /alerts/{alert_configuration_id}`, but is otherwise the + /// Returns a raw HTTP response for put /alerts/{alert_configuration_id}, but is otherwise the /// same as . /// Task> Update( @@ -215,7 +223,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /alerts`, but is otherwise the + /// Returns a raw HTTP response for get /alerts, but is otherwise the /// same as . /// Task> List( @@ -224,7 +232,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /alerts/customer_id/{customer_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/customer_id/{customer_id}, but is otherwise the /// same as . /// Task> CreateForCustomer( @@ -240,7 +248,7 @@ Task> CreateForCustomer( ); /// - /// Returns a raw HTTP response for `post /alerts/external_customer_id/{external_customer_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/external_customer_id/{external_customer_id}, but is otherwise the /// same as . /// Task> CreateForExternalCustomer( @@ -256,7 +264,7 @@ Task> CreateForExternalCustomer( ); /// - /// Returns a raw HTTP response for `post /alerts/subscription_id/{subscription_id}`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/subscription_id/{subscription_id}, but is otherwise the /// same as . /// Task> CreateForSubscription( @@ -272,7 +280,7 @@ Task> CreateForSubscription( ); /// - /// Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/disable`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/{alert_configuration_id}/disable, but is otherwise the /// same as . /// Task> Disable( @@ -288,7 +296,7 @@ Task> Disable( ); /// - /// Returns a raw HTTP response for `post /alerts/{alert_configuration_id}/enable`, but is otherwise the + /// Returns a raw HTTP response for post /alerts/{alert_configuration_id}/enable, but is otherwise the /// same as . /// Task> Enable( diff --git a/src/Orb/Services/IBetaService.cs b/src/Orb/Services/IBetaService.cs index 4b42c1c9d..8eccad363 100644 --- a/src/Orb/Services/IBetaService.cs +++ b/src/Orb/Services/IBetaService.cs @@ -9,9 +9,13 @@ namespace Orb.Services; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The [Plan](/core-concepts#plan-and-price) resource represents a plan that can +/// be subscribed to by a customer. Plans define the billing behavior of the subscription. +/// You can see more about how to configure prices in the [Price resource](/reference/price). +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IBetaService { @@ -93,7 +97,7 @@ public interface IBetaServiceWithRawResponse IExternalPlanIDServiceWithRawResponse ExternalPlanID { get; } /// - /// Returns a raw HTTP response for `post /plans/{plan_id}/versions`, but is otherwise the + /// Returns a raw HTTP response for post /plans/{plan_id}/versions, but is otherwise the /// same as . /// Task> CreatePlanVersion( @@ -109,7 +113,7 @@ Task> CreatePlanVersion( ); /// - /// Returns a raw HTTP response for `get /plans/{plan_id}/versions/{version}`, but is otherwise the + /// Returns a raw HTTP response for get /plans/{plan_id}/versions/{version}, but is otherwise the /// same as . /// Task> FetchPlanVersion( @@ -125,7 +129,7 @@ Task> FetchPlanVersion( ); /// - /// Returns a raw HTTP response for `post /plans/{plan_id}/set_default_version`, but is otherwise the + /// Returns a raw HTTP response for post /plans/{plan_id}/set_default_version, but is otherwise the /// same as . /// Task> SetDefaultPlanVersion( diff --git a/src/Orb/Services/ICouponService.cs b/src/Orb/Services/ICouponService.cs index bb02e0542..126bc5ae0 100644 --- a/src/Orb/Services/ICouponService.cs +++ b/src/Orb/Services/ICouponService.cs @@ -8,9 +8,14 @@ namespace Orb.Services; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// A coupon represents a reusable discount configuration that can be applied either +/// as a fixed or percentage amount to an invoice or subscription. Coupons are activated +/// using a redemption code, which applies the discount to a subscription or invoice. +/// The duration of a coupon determines how long it remains available for use by end users. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface ICouponService { @@ -30,8 +35,8 @@ public interface ICouponService Coupons::ISubscriptionService Subscriptions { get; } /// - /// This endpoint allows the creation of coupons, which can then be redeemed - /// at subscription creation or plan change. + /// This endpoint allows the creation of coupons, which can then be redeemed at + /// subscription creation or plan change. /// Task Create( CouponCreateParams parameters, @@ -43,8 +48,7 @@ Task Create( /// /// The list of coupons is ordered starting from the most recently created /// coupon. The response also includes `pagination_metadata`, which lets the caller - /// retrieve the next page of results if they exist. More information about pagination - /// can be found in the Pagination-metadata schema. + /// retrieve the next page of results if they exist. /// Task List( CouponListParams? parameters = null, @@ -52,9 +56,9 @@ Task List( ); /// - /// This endpoint allows a coupon to be archived. Archived coupons can no longer - /// be redeemed, and will be hidden from lists of active coupons. Additionally, - /// once a coupon is archived, its redemption code can be reused for a different coupon. + /// This endpoint allows a coupon to be archived. Archived coupons can no longer be + /// redeemed, and will be hidden from lists of active coupons. Additionally, once a + /// coupon is archived, its redemption code can be reused for a different coupon. /// Task Archive( CouponArchiveParams parameters, @@ -70,7 +74,8 @@ Task Archive( /// /// This endpoint retrieves a coupon by its ID. To fetch coupons by their redemption - /// code, use the [List coupons](list-coupons) endpoint with the redemption_code parameter. + /// code, use the [List coupons](list-coupons) endpoint with the redemption_code + /// parameter. /// Task Fetch(CouponFetchParams parameters, CancellationToken cancellationToken = default); @@ -98,7 +103,7 @@ public interface ICouponServiceWithRawResponse Coupons::ISubscriptionServiceWithRawResponse Subscriptions { get; } /// - /// Returns a raw HTTP response for `post /coupons`, but is otherwise the + /// Returns a raw HTTP response for post /coupons, but is otherwise the /// same as . /// Task> Create( @@ -107,7 +112,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `get /coupons`, but is otherwise the + /// Returns a raw HTTP response for get /coupons, but is otherwise the /// same as . /// Task> List( @@ -116,7 +121,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `post /coupons/{coupon_id}/archive`, but is otherwise the + /// Returns a raw HTTP response for post /coupons/{coupon_id}/archive, but is otherwise the /// same as . /// Task> Archive( @@ -132,7 +137,7 @@ Task> Archive( ); /// - /// Returns a raw HTTP response for `get /coupons/{coupon_id}`, but is otherwise the + /// Returns a raw HTTP response for get /coupons/{coupon_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/ICreditBlockService.cs b/src/Orb/Services/ICreditBlockService.cs index c2d358645..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..6fae3aa5b 100644 --- a/src/Orb/Services/IMetricService.cs +++ b/src/Orb/Services/IMetricService.cs @@ -7,9 +7,13 @@ namespace Orb.Services; /// -/// NOTE: Do not inherit from this type outside the SDK unless you're okay with breaking -/// changes in non-major versions. We may add new methods in the future that cause -/// existing derived classes to break. +/// The Metric resource represents a calculation of a quantity based on events. Metrics +/// are defined by the query that transforms raw usage events into meaningful values +/// for your customers. +/// +/// NOTE: Do not inherit from this type outside the SDK unless you're okay with +/// breaking changes in non-major versions. We may add new methods in the future that +/// cause existing derived classes to break. /// public interface IMetricService { @@ -27,9 +31,9 @@ public interface IMetricService IMetricService WithOptions(Func modifier); /// - /// This endpoint is used to create a [metric](/core-concepts###metric) using - /// a SQL string. See [SQL support](/extensibility/advanced-metrics#sql-support) - /// for a description of constructing SQL queries with examples. + /// This endpoint is used to create a [metric](/core-concepts###metric) using a SQL + /// string. See [SQL support](/extensibility/advanced-metrics#sql-support) for a + /// description of constructing SQL queries with examples. /// Task Create( MetricCreateParams parameters, @@ -37,9 +41,9 @@ Task Create( ); /// - /// This endpoint allows you to update the `metadata` property on a metric. If - /// you pass `null` for the metadata value, it will clear any existing metadata - /// for that invoice. + /// This endpoint allows you to update the `metadata` property on a metric. If you + /// pass `null` for the metadata value, it will clear any existing metadata for that + /// invoice. /// Task Update( MetricUpdateParams parameters, @@ -54,9 +58,9 @@ Task Update( ); /// - /// This endpoint is used to fetch [metric](/core-concepts##metric) details given - /// a metric identifier. It returns information about the metrics including its - /// name, description, and item. + /// This endpoint is used to fetch [metric](/core-concepts##metric) details given a + /// metric identifier. It returns information about the metrics including its name, + /// description, and item. /// Task List( MetricListParams? parameters = null, @@ -94,7 +98,7 @@ public interface IMetricServiceWithRawResponse IMetricServiceWithRawResponse WithOptions(Func modifier); /// - /// Returns a raw HTTP response for `post /metrics`, but is otherwise the + /// Returns a raw HTTP response for post /metrics, but is otherwise the /// same as . /// Task> Create( @@ -103,7 +107,7 @@ Task> Create( ); /// - /// Returns a raw HTTP response for `put /metrics/{metric_id}`, but is otherwise the + /// Returns a raw HTTP response for put /metrics/{metric_id}, but is otherwise the /// same as . /// Task> Update( @@ -119,7 +123,7 @@ Task> Update( ); /// - /// Returns a raw HTTP response for `get /metrics`, but is otherwise the + /// Returns a raw HTTP response for get /metrics, but is otherwise the /// same as . /// Task> List( @@ -128,7 +132,7 @@ Task> List( ); /// - /// Returns a raw HTTP response for `get /metrics/{metric_id}`, but is otherwise the + /// Returns a raw HTTP response for get /metrics/{metric_id}, but is otherwise the /// same as . /// Task> Fetch( diff --git a/src/Orb/Services/IPlanService.cs b/src/Orb/Services/IPlanService.cs index e7eac2227..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