@seamapi/nextlove-sdk-generator 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.txt +20 -0
- package/README.md +16 -0
- package/index.d.ts +6 -0
- package/index.js +7 -0
- package/index.js.map +1 -0
- package/lib/cli.d.ts +2 -0
- package/lib/cli.js +53 -0
- package/lib/cli.js.map +1 -0
- package/lib/fs-util/index.d.ts +2 -0
- package/lib/fs-util/index.js +3 -0
- package/lib/fs-util/index.js.map +1 -0
- package/lib/fs-util/populate-fs.d.ts +1 -0
- package/lib/fs-util/populate-fs.js +11 -0
- package/lib/fs-util/populate-fs.js.map +1 -0
- package/lib/fs-util/write-fs.d.ts +1 -0
- package/lib/fs-util/write-fs.js +10 -0
- package/lib/fs-util/write-fs.js.map +1 -0
- package/lib/generate-csharp-sdk/codegen.d.ts +235 -0
- package/lib/generate-csharp-sdk/codegen.js +432 -0
- package/lib/generate-csharp-sdk/codegen.js.map +1 -0
- package/lib/generate-csharp-sdk/constants.d.ts +1 -0
- package/lib/generate-csharp-sdk/constants.js +2 -0
- package/lib/generate-csharp-sdk/constants.js.map +1 -0
- package/lib/generate-csharp-sdk/generate-csharp-sdk.d.ts +1 -0
- package/lib/generate-csharp-sdk/generate-csharp-sdk.js +81 -0
- package/lib/generate-csharp-sdk/generate-csharp-sdk.js.map +1 -0
- package/lib/generate-csharp-sdk/generate-csproj.d.ts +1 -0
- package/lib/generate-csharp-sdk/generate-csproj.js +45 -0
- package/lib/generate-csharp-sdk/generate-csproj.js.map +1 -0
- package/lib/generate-csharp-sdk/templates/dataclass.d.ts +24 -0
- package/lib/generate-csharp-sdk/templates/dataclass.js +468 -0
- package/lib/generate-csharp-sdk/templates/dataclass.js.map +1 -0
- package/lib/generate-csharp-sdk/templates/fs/csharp-testing.sln +34 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ApiResponse.cs +159 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ClientUtils.cs +280 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ExceptionFactory.cs +12 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/GlobalSeamRequestConfiguration.cs +60 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/HttpMethod.cs +29 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/IAsynchronousSeam.cs +142 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/IReadableSeamRequestConfiguration.cs +68 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ISynchronousSeam.cs +103 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/Multimap.cs +286 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/RequestOptions.cs +74 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/RetryConfiguration.cs +21 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/Seam.cs +1070 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/SeamException.cs +64 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/SeamRequestConfiguration.cs +662 -0
- package/lib/generate-csharp-sdk/templates/fs/src/Seam/Model/AsbtractModelSchema.cs +62 -0
- package/lib/generate-php-sdk/generate-php-sdk.d.ts +1 -0
- package/lib/generate-php-sdk/generate-php-sdk.js +127 -0
- package/lib/generate-php-sdk/generate-php-sdk.js.map +1 -0
- package/lib/generate-php-sdk/index.d.ts +1 -0
- package/lib/generate-php-sdk/index.js +2 -0
- package/lib/generate-php-sdk/index.js.map +1 -0
- package/lib/generate-php-sdk/templates/composer.json.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/composer.json.template.js +25 -0
- package/lib/generate-php-sdk/templates/composer.json.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/env.example.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/env.example.template.js +4 -0
- package/lib/generate-php-sdk/templates/env.example.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/gitignore.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/gitignore.template.js +6 -0
- package/lib/generate-php-sdk/templates/gitignore.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/package.json.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/package.json.template.js +12 -0
- package/lib/generate-php-sdk/templates/package.json.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/readme.md.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/readme.md.template.js +86 -0
- package/lib/generate-php-sdk/templates/readme.md.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/smoke-test.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/smoke-test.template.js +30 -0
- package/lib/generate-php-sdk/templates/smoke-test.template.js.map +1 -0
- package/lib/generate-php-sdk/templates/test-fixture.template.d.ts +2 -0
- package/lib/generate-php-sdk/templates/test-fixture.template.js +21 -0
- package/lib/generate-php-sdk/templates/test-fixture.template.js.map +1 -0
- package/lib/generate-php-sdk/utils/deep-extract-resource-object-schemas.d.ts +16 -0
- package/lib/generate-php-sdk/utils/deep-extract-resource-object-schemas.js +97 -0
- package/lib/generate-php-sdk/utils/deep-extract-resource-object-schemas.js.map +1 -0
- package/lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.d.ts +2 -0
- package/lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.js +95 -0
- package/lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.js.map +1 -0
- package/lib/generate-php-sdk/utils/generate-resource-object-class.d.ts +8 -0
- package/lib/generate-php-sdk/utils/generate-resource-object-class.js +73 -0
- package/lib/generate-php-sdk/utils/generate-resource-object-class.js.map +1 -0
- package/lib/generate-php-sdk/utils/generate-seam-client.d.ts +7 -0
- package/lib/generate-php-sdk/utils/generate-seam-client.js +103 -0
- package/lib/generate-php-sdk/utils/generate-seam-client.js.map +1 -0
- package/lib/generate-php-sdk/utils/get-php-type.d.ts +1 -0
- package/lib/generate-php-sdk/utils/get-php-type.js +17 -0
- package/lib/generate-php-sdk/utils/get-php-type.js.map +1 -0
- package/lib/generate-php-sdk/utils/php-client.d.ts +31 -0
- package/lib/generate-php-sdk/utils/php-client.js +130 -0
- package/lib/generate-php-sdk/utils/php-client.js.map +1 -0
- package/lib/generate-python-sdk/class-file.d.ts +20 -0
- package/lib/generate-python-sdk/class-file.js +75 -0
- package/lib/generate-python-sdk/class-file.js.map +1 -0
- package/lib/generate-python-sdk/generate-python-sdk.d.ts +1 -0
- package/lib/generate-python-sdk/generate-python-sdk.js +117 -0
- package/lib/generate-python-sdk/generate-python-sdk.js.map +1 -0
- package/lib/generate-python-sdk/index.d.ts +1 -0
- package/lib/generate-python-sdk/index.js +2 -0
- package/lib/generate-python-sdk/index.js.map +1 -0
- package/lib/generate-python-sdk/map-python-type.d.ts +2 -0
- package/lib/generate-python-sdk/map-python-type.js +26 -0
- package/lib/generate-python-sdk/map-python-type.js.map +1 -0
- package/lib/generate-python-sdk/templates/conftest.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/conftest.py.template.js +12 -0
- package/lib/generate-python-sdk/templates/conftest.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/pyproject.toml.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/pyproject.toml.template.js +21 -0
- package/lib/generate-python-sdk/templates/pyproject.toml.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/readme.md.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/readme.md.template.js +48 -0
- package/lib/generate-python-sdk/templates/readme.md.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/routes.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/routes.py.template.js +13 -0
- package/lib/generate-python-sdk/templates/routes.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/seam.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/seam.py.template.js +74 -0
- package/lib/generate-python-sdk/templates/seam.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js +9 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-routes.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js +9 -0
- package/lib/generate-python-sdk/templates/snippets/abstract-seam.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.d.ts +5 -0
- package/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.js +10 -0
- package/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/test_smoke.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/test_smoke.py.template.js +13 -0
- package/lib/generate-python-sdk/templates/test_smoke.py.template.js.map +1 -0
- package/lib/generate-python-sdk/templates/utils/deep_attr_dict.py.template.d.ts +2 -0
- package/lib/generate-python-sdk/templates/utils/deep_attr_dict.py.template.js +28 -0
- package/lib/generate-python-sdk/templates/utils/deep_attr_dict.py.template.js.map +1 -0
- package/lib/generate-ruby-sdk/generate-ruby-sdk.d.ts +1 -0
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js +132 -0
- package/lib/generate-ruby-sdk/generate-ruby-sdk.js.map +1 -0
- package/lib/generate-ruby-sdk/index.d.ts +1 -0
- package/lib/generate-ruby-sdk/index.js +2 -0
- package/lib/generate-ruby-sdk/index.js.map +1 -0
- package/lib/generate-ruby-sdk/request.rb.template.d.ts +1 -0
- package/lib/generate-ruby-sdk/request.rb.template.js +2 -0
- package/lib/generate-ruby-sdk/request.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/ruby-client.d.ts +35 -0
- package/lib/generate-ruby-sdk/ruby-client.js +59 -0
- package/lib/generate-ruby-sdk/ruby-client.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/base_client.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/base_client.rb.template.js +22 -0
- package/lib/generate-ruby-sdk/templates/base_client.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.js +59 -0
- package/lib/generate-ruby-sdk/templates/base_resource.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/client.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/client.rb.template.js +74 -0
- package/lib/generate-ruby-sdk/templates/client.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/gemfile.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/gemfile.template.js +7 -0
- package/lib/generate-ruby-sdk/templates/gemfile.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/logger.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/logger.rb.template.js +13 -0
- package/lib/generate-ruby-sdk/templates/logger.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/rakefile.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/rakefile.template.js +23 -0
- package/lib/generate-ruby-sdk/templates/rakefile.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/readme.md.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/readme.md.template.js +184 -0
- package/lib/generate-ruby-sdk/templates/readme.md.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/request.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/request.rb.template.js +71 -0
- package/lib/generate-ruby-sdk/templates/request.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js +8 -0
- package/lib/generate-ruby-sdk/templates/resource_error.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.js +10 -0
- package/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js +8 -0
- package/lib/generate-ruby-sdk/templates/resource_warning.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.js +10 -0
- package/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.js +41 -0
- package/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.d.ts +6 -0
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js +15 -0
- package/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.js.map +1 -0
- package/lib/generate-ruby-sdk/templates/version.rb.template.d.ts +2 -0
- package/lib/generate-ruby-sdk/templates/version.rb.template.js +6 -0
- package/lib/generate-ruby-sdk/templates/version.rb.template.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.js +3 -0
- package/lib/index.js.map +1 -0
- package/lib/openapi/flatten-obj-schema.d.ts +5 -0
- package/lib/openapi/flatten-obj-schema.js +86 -0
- package/lib/openapi/flatten-obj-schema.js.map +1 -0
- package/lib/openapi/get-parameter-and-response-schema.d.ts +20 -0
- package/lib/openapi/get-parameter-and-response-schema.js +42 -0
- package/lib/openapi/get-parameter-and-response-schema.js.map +1 -0
- package/lib/openapi/index.d.ts +2 -0
- package/lib/openapi/index.js +3 -0
- package/lib/openapi/index.js.map +1 -0
- package/lib/types.d.ts +91 -0
- package/lib/types.js +2 -0
- package/lib/types.js.map +1 -0
- package/package.json +95 -0
- package/src/index.ts +6 -0
- package/src/lib/cli.ts +71 -0
- package/src/lib/fs-util/index.ts +2 -0
- package/src/lib/fs-util/populate-fs.ts +14 -0
- package/src/lib/fs-util/write-fs.ts +10 -0
- package/src/lib/generate-csharp-sdk/codegen.ts +648 -0
- package/src/lib/generate-csharp-sdk/constants.ts +1 -0
- package/src/lib/generate-csharp-sdk/generate-csharp-sdk.ts +126 -0
- package/src/lib/generate-csharp-sdk/generate-csproj.ts +45 -0
- package/src/lib/generate-csharp-sdk/templates/dataclass.ts +973 -0
- package/src/lib/generate-csharp-sdk/templates/fs/csharp-testing.sln +34 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ApiResponse.cs +159 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ClientUtils.cs +280 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ExceptionFactory.cs +12 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/GlobalSeamRequestConfiguration.cs +60 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/HttpMethod.cs +29 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/IAsynchronousSeam.cs +142 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/IReadableSeamRequestConfiguration.cs +68 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/ISynchronousSeam.cs +103 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/Multimap.cs +286 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/RequestOptions.cs +74 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/RetryConfiguration.cs +21 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/Seam.cs +1070 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/SeamException.cs +64 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Client/SeamRequestConfiguration.cs +662 -0
- package/src/lib/generate-csharp-sdk/templates/fs/src/Seam/Model/AsbtractModelSchema.cs +62 -0
- package/src/lib/generate-php-sdk/generate-php-sdk.ts +176 -0
- package/src/lib/generate-php-sdk/index.ts +1 -0
- package/src/lib/generate-php-sdk/templates/composer.json.template.ts +24 -0
- package/src/lib/generate-php-sdk/templates/env.example.template.ts +3 -0
- package/src/lib/generate-php-sdk/templates/gitignore.template.ts +5 -0
- package/src/lib/generate-php-sdk/templates/package.json.template.ts +11 -0
- package/src/lib/generate-php-sdk/templates/readme.md.template.ts +85 -0
- package/src/lib/generate-php-sdk/templates/smoke-test.template.ts +29 -0
- package/src/lib/generate-php-sdk/templates/test-fixture.template.ts +20 -0
- package/src/lib/generate-php-sdk/utils/deep-extract-resource-object-schemas.ts +160 -0
- package/src/lib/generate-php-sdk/utils/deep-flatten-one-of-and-all-of-schema.ts +128 -0
- package/src/lib/generate-php-sdk/utils/generate-resource-object-class.ts +105 -0
- package/src/lib/generate-php-sdk/utils/generate-seam-client.ts +115 -0
- package/src/lib/generate-php-sdk/utils/get-php-type.ts +21 -0
- package/src/lib/generate-php-sdk/utils/php-client.ts +189 -0
- package/src/lib/generate-python-sdk/class-file.ts +114 -0
- package/src/lib/generate-python-sdk/generate-python-sdk.ts +147 -0
- package/src/lib/generate-python-sdk/index.ts +1 -0
- package/src/lib/generate-python-sdk/map-python-type.ts +29 -0
- package/src/lib/generate-python-sdk/templates/conftest.py.template.ts +11 -0
- package/src/lib/generate-python-sdk/templates/pyproject.toml.template.ts +20 -0
- package/src/lib/generate-python-sdk/templates/readme.md.template.ts +47 -0
- package/src/lib/generate-python-sdk/templates/routes.py.template.ts +13 -0
- package/src/lib/generate-python-sdk/templates/seam.py.template.ts +73 -0
- package/src/lib/generate-python-sdk/templates/snippets/abstract-routes.template.ts +9 -0
- package/src/lib/generate-python-sdk/templates/snippets/abstract-seam.template.ts +8 -0
- package/src/lib/generate-python-sdk/templates/snippets/resource-dataclass.template.ts +15 -0
- package/src/lib/generate-python-sdk/templates/test_smoke.py.template.ts +12 -0
- package/src/lib/generate-python-sdk/templates/utils/deep_attr_dict.py.template.ts +27 -0
- package/src/lib/generate-ruby-sdk/generate-ruby-sdk.ts +153 -0
- package/src/lib/generate-ruby-sdk/index.ts +1 -0
- package/src/lib/generate-ruby-sdk/request.rb.template.ts +0 -0
- package/src/lib/generate-ruby-sdk/ruby-client.ts +81 -0
- package/src/lib/generate-ruby-sdk/templates/base_client.rb.template.ts +21 -0
- package/src/lib/generate-ruby-sdk/templates/base_resource.rb.template.ts +58 -0
- package/src/lib/generate-ruby-sdk/templates/client.rb.template.ts +73 -0
- package/src/lib/generate-ruby-sdk/templates/gemfile.template.ts +6 -0
- package/src/lib/generate-ruby-sdk/templates/logger.rb.template.ts +12 -0
- package/src/lib/generate-ruby-sdk/templates/rakefile.template.ts +22 -0
- package/src/lib/generate-ruby-sdk/templates/readme.md.template.ts +183 -0
- package/src/lib/generate-ruby-sdk/templates/request.rb.template.ts +70 -0
- package/src/lib/generate-ruby-sdk/templates/resource_error.rb.template.ts +7 -0
- package/src/lib/generate-ruby-sdk/templates/resource_errors_support.rb.template.ts +9 -0
- package/src/lib/generate-ruby-sdk/templates/resource_warning.rb.template.ts +7 -0
- package/src/lib/generate-ruby-sdk/templates/resource_warnings_support.rb.template.ts +9 -0
- package/src/lib/generate-ruby-sdk/templates/seamapi.gemspec.template.ts +40 -0
- package/src/lib/generate-ruby-sdk/templates/snippets/resource.rb.template.ts +24 -0
- package/src/lib/generate-ruby-sdk/templates/version.rb.template.ts +5 -0
- package/src/lib/index.ts +2 -0
- package/src/lib/openapi/flatten-obj-schema.ts +124 -0
- package/src/lib/openapi/get-parameter-and-response-schema.ts +59 -0
- package/src/lib/openapi/index.ts +2 -0
- package/src/lib/types.ts +96 -0
|
@@ -0,0 +1,662 @@
|
|
|
1
|
+
using System;
|
|
2
|
+
using System.Collections.Concurrent;
|
|
3
|
+
using System.Collections.Generic;
|
|
4
|
+
using System.IO;
|
|
5
|
+
using System.Linq;
|
|
6
|
+
using System.Net;
|
|
7
|
+
using System.Reflection;
|
|
8
|
+
using System.Security.Cryptography.X509Certificates;
|
|
9
|
+
using System.Text;
|
|
10
|
+
using System.Net.Http;
|
|
11
|
+
using System.Net.Security;
|
|
12
|
+
|
|
13
|
+
namespace Seam.Client
|
|
14
|
+
{
|
|
15
|
+
/// <summary>
|
|
16
|
+
/// Represents a set of configuration settings
|
|
17
|
+
/// </summary>
|
|
18
|
+
public class SeamRequestConfiguration : IReadableSeamRequestConfiguration
|
|
19
|
+
{
|
|
20
|
+
#region Constants
|
|
21
|
+
|
|
22
|
+
/// <summary>
|
|
23
|
+
/// Version of the package.
|
|
24
|
+
/// </summary>
|
|
25
|
+
/// <value>Version of the package.</value>
|
|
26
|
+
public const string Version = "1.0.0";
|
|
27
|
+
|
|
28
|
+
/// <summary>
|
|
29
|
+
/// Identifier for ISO 8601 DateTime Format
|
|
30
|
+
/// </summary>
|
|
31
|
+
/// <remarks>See https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx#Anchor_8 for more information.</remarks>
|
|
32
|
+
// ReSharper disable once InconsistentNaming
|
|
33
|
+
public const string ISO8601_DATETIME_FORMAT = "o";
|
|
34
|
+
|
|
35
|
+
#endregion Constants
|
|
36
|
+
|
|
37
|
+
#region Static Members
|
|
38
|
+
|
|
39
|
+
/// <summary>
|
|
40
|
+
/// Default creation of exceptions for a given method name and response object
|
|
41
|
+
/// </summary>
|
|
42
|
+
public static readonly ExceptionFactory DefaultExceptionFactory = (methodName, response) =>
|
|
43
|
+
{
|
|
44
|
+
var status = (int)response.StatusCode;
|
|
45
|
+
if (status >= 400)
|
|
46
|
+
{
|
|
47
|
+
return new SeamException(
|
|
48
|
+
status,
|
|
49
|
+
string.Format("Error calling {0}: {1}", methodName, response.RawContent),
|
|
50
|
+
response.RawContent,
|
|
51
|
+
response.Headers
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (status == 0)
|
|
55
|
+
{
|
|
56
|
+
return new SeamException(
|
|
57
|
+
status,
|
|
58
|
+
string.Format("Error calling {0}: {1}", methodName, response.ErrorText),
|
|
59
|
+
response.ErrorText
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
#endregion Static Members
|
|
66
|
+
|
|
67
|
+
#region Private Members
|
|
68
|
+
|
|
69
|
+
/// <summary>
|
|
70
|
+
/// Defines the base path of the target API server.
|
|
71
|
+
/// Example: http://localhost:3000/v1/
|
|
72
|
+
/// </summary>
|
|
73
|
+
private string _basePath;
|
|
74
|
+
|
|
75
|
+
private bool _useDefaultCredentials = false;
|
|
76
|
+
|
|
77
|
+
/// <summary>
|
|
78
|
+
/// Gets or sets the API key based on the authentication name.
|
|
79
|
+
/// This is the key and value comprising the "secret" for accessing an API.
|
|
80
|
+
/// </summary>
|
|
81
|
+
/// <value>The API key.</value>
|
|
82
|
+
private IDictionary<string, string> _apiKey;
|
|
83
|
+
|
|
84
|
+
/// <summary>
|
|
85
|
+
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
|
86
|
+
/// </summary>
|
|
87
|
+
/// <value>The prefix of the API key.</value>
|
|
88
|
+
private IDictionary<string, string> _apiKeyPrefix;
|
|
89
|
+
|
|
90
|
+
private string _dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
91
|
+
private string _tempFolderPath = Path.GetTempPath();
|
|
92
|
+
|
|
93
|
+
/// <summary>
|
|
94
|
+
/// Gets or sets the servers defined in the OpenAPI spec.
|
|
95
|
+
/// </summary>
|
|
96
|
+
/// <value>The servers</value>
|
|
97
|
+
private IList<IReadOnlyDictionary<string, object>> _servers;
|
|
98
|
+
|
|
99
|
+
/// <summary>
|
|
100
|
+
/// Gets or sets the operation servers defined in the OpenAPI spec.
|
|
101
|
+
/// </summary>
|
|
102
|
+
/// <value>The operation servers</value>
|
|
103
|
+
private IReadOnlyDictionary<
|
|
104
|
+
string,
|
|
105
|
+
List<IReadOnlyDictionary<string, object>>
|
|
106
|
+
> _operationServers;
|
|
107
|
+
|
|
108
|
+
#endregion Private Members
|
|
109
|
+
|
|
110
|
+
#region Constructors
|
|
111
|
+
|
|
112
|
+
/// <summary>
|
|
113
|
+
/// Initializes a new instance of the <see cref="Configuration" /> class
|
|
114
|
+
/// </summary>
|
|
115
|
+
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
|
116
|
+
"ReSharper",
|
|
117
|
+
"VirtualMemberCallInConstructor"
|
|
118
|
+
)]
|
|
119
|
+
public SeamRequestConfiguration()
|
|
120
|
+
{
|
|
121
|
+
Proxy = null;
|
|
122
|
+
UserAgent = WebUtility.UrlEncode("OpenAPI-Generator/1.0.0/csharp");
|
|
123
|
+
BasePath = "https://connect.getseam.com";
|
|
124
|
+
DefaultHeaders = new ConcurrentDictionary<string, string>();
|
|
125
|
+
ApiKey = new ConcurrentDictionary<string, string>();
|
|
126
|
+
ApiKeyPrefix = new ConcurrentDictionary<string, string>();
|
|
127
|
+
Servers = new List<IReadOnlyDictionary<string, object>>()
|
|
128
|
+
{
|
|
129
|
+
{
|
|
130
|
+
new Dictionary<string, object>
|
|
131
|
+
{
|
|
132
|
+
{ "url", "https://connect.getseam.com" },
|
|
133
|
+
{ "description", "No description provided" },
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
OperationServers = new Dictionary<string, List<IReadOnlyDictionary<string, object>>>()
|
|
138
|
+
{
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
// Setting Timeout has side effects (forces ApiClient creation).
|
|
142
|
+
Timeout = 100000;
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/// <summary>
|
|
146
|
+
/// Initializes a new instance of the <see cref="Configuration" /> class
|
|
147
|
+
/// </summary>
|
|
148
|
+
[System.Diagnostics.CodeAnalysis.SuppressMessage(
|
|
149
|
+
"ReSharper",
|
|
150
|
+
"VirtualMemberCallInConstructor"
|
|
151
|
+
)]
|
|
152
|
+
public SeamRequestConfiguration(
|
|
153
|
+
IDictionary<string, string> defaultHeaders,
|
|
154
|
+
// IDictionary<string, string> apiKey,
|
|
155
|
+
// IDictionary<string, string> apiKeyPrefix,
|
|
156
|
+
string basePath = "https://connect.getseam.com"
|
|
157
|
+
)
|
|
158
|
+
: this()
|
|
159
|
+
{
|
|
160
|
+
if (string.IsNullOrWhiteSpace(basePath))
|
|
161
|
+
throw new ArgumentException("The provided basePath is invalid.", "basePath");
|
|
162
|
+
if (defaultHeaders == null)
|
|
163
|
+
throw new ArgumentNullException("defaultHeaders");
|
|
164
|
+
// if (apiKey == null)
|
|
165
|
+
// throw new ArgumentNullException("apiKey");
|
|
166
|
+
// if (apiKeyPrefix == null)
|
|
167
|
+
// throw new ArgumentNullException("apiKeyPrefix");
|
|
168
|
+
|
|
169
|
+
BasePath = basePath;
|
|
170
|
+
|
|
171
|
+
foreach (var keyValuePair in defaultHeaders)
|
|
172
|
+
{
|
|
173
|
+
DefaultHeaders.Add(keyValuePair);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
// foreach (var keyValuePair in apiKey)
|
|
177
|
+
// {
|
|
178
|
+
// ApiKey.Add(keyValuePair);
|
|
179
|
+
// }
|
|
180
|
+
|
|
181
|
+
// foreach (var keyValuePair in apiKeyPrefix)
|
|
182
|
+
// {
|
|
183
|
+
// ApiKeyPrefix.Add(keyValuePair);
|
|
184
|
+
// }
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
#endregion Constructors
|
|
188
|
+
|
|
189
|
+
#region Properties
|
|
190
|
+
|
|
191
|
+
/// <summary>
|
|
192
|
+
/// Gets or sets the base path for API access.
|
|
193
|
+
/// </summary>
|
|
194
|
+
public virtual string BasePath
|
|
195
|
+
{
|
|
196
|
+
get { return _basePath; }
|
|
197
|
+
set { _basePath = value; }
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/// <summary>
|
|
201
|
+
/// Determine whether or not the "default credentials" (e.g. the user account under which the current process is running) will be sent along to the server. The default is false.
|
|
202
|
+
/// </summary>
|
|
203
|
+
public virtual bool UseDefaultCredentials
|
|
204
|
+
{
|
|
205
|
+
get { return _useDefaultCredentials; }
|
|
206
|
+
set { _useDefaultCredentials = value; }
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/// <summary>
|
|
210
|
+
/// Gets or sets the default header.
|
|
211
|
+
/// </summary>
|
|
212
|
+
[Obsolete("Use DefaultHeaders instead.")]
|
|
213
|
+
public virtual IDictionary<string, string> DefaultHeader
|
|
214
|
+
{
|
|
215
|
+
get { return DefaultHeaders; }
|
|
216
|
+
set { DefaultHeaders = value; }
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/// <summary>
|
|
220
|
+
/// Gets or sets the default headers.
|
|
221
|
+
/// </summary>
|
|
222
|
+
public virtual IDictionary<string, string> DefaultHeaders { get; set; }
|
|
223
|
+
|
|
224
|
+
/// <summary>
|
|
225
|
+
/// Gets or sets the HTTP timeout (milliseconds) of ApiClient. Default to 100000 milliseconds.
|
|
226
|
+
/// </summary>
|
|
227
|
+
public virtual int Timeout { get; set; }
|
|
228
|
+
|
|
229
|
+
/// <summary>
|
|
230
|
+
/// Gets or sets the proxy
|
|
231
|
+
/// </summary>
|
|
232
|
+
/// <value>Proxy.</value>
|
|
233
|
+
public virtual WebProxy Proxy { get; set; }
|
|
234
|
+
|
|
235
|
+
/// <summary>
|
|
236
|
+
/// Gets or sets the HTTP user agent.
|
|
237
|
+
/// </summary>
|
|
238
|
+
/// <value>Http user agent.</value>
|
|
239
|
+
public virtual string UserAgent { get; set; }
|
|
240
|
+
|
|
241
|
+
/// <summary>
|
|
242
|
+
/// Gets or sets the username (HTTP basic authentication).
|
|
243
|
+
/// </summary>
|
|
244
|
+
/// <value>The username.</value>
|
|
245
|
+
public virtual string Username { get; set; }
|
|
246
|
+
|
|
247
|
+
/// <summary>
|
|
248
|
+
/// Gets or sets the password (HTTP basic authentication).
|
|
249
|
+
/// </summary>
|
|
250
|
+
/// <value>The password.</value>
|
|
251
|
+
public virtual string Password { get; set; }
|
|
252
|
+
|
|
253
|
+
/// <summary>
|
|
254
|
+
/// Gets the API key with prefix.
|
|
255
|
+
/// </summary>
|
|
256
|
+
/// <param name="apiKeyIdentifier">API key identifier (authentication scheme).</param>
|
|
257
|
+
/// <returns>API key with prefix.</returns>
|
|
258
|
+
public string GetApiKeyWithPrefix(string apiKeyIdentifier)
|
|
259
|
+
{
|
|
260
|
+
string apiKeyValue;
|
|
261
|
+
ApiKey.TryGetValue(apiKeyIdentifier, out apiKeyValue);
|
|
262
|
+
string apiKeyPrefix;
|
|
263
|
+
if (ApiKeyPrefix.TryGetValue(apiKeyIdentifier, out apiKeyPrefix))
|
|
264
|
+
{
|
|
265
|
+
return apiKeyPrefix + " " + apiKeyValue;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
return apiKeyValue;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
/// <summary>
|
|
272
|
+
/// Gets or sets certificate collection to be sent with requests.
|
|
273
|
+
/// </summary>
|
|
274
|
+
/// <value>X509 Certificate collection.</value>
|
|
275
|
+
public X509CertificateCollection ClientCertificates { get; set; }
|
|
276
|
+
|
|
277
|
+
/// <summary>
|
|
278
|
+
/// Gets or sets the access token for OAuth2 authentication.
|
|
279
|
+
///
|
|
280
|
+
/// This helper property simplifies code generation.
|
|
281
|
+
/// </summary>
|
|
282
|
+
/// <value>The access token.</value>
|
|
283
|
+
public virtual string ApiToken { get; set; }
|
|
284
|
+
|
|
285
|
+
/// <summary>
|
|
286
|
+
/// Gets or sets the temporary folder path to store the files downloaded from the server.
|
|
287
|
+
/// </summary>
|
|
288
|
+
/// <value>Folder path.</value>
|
|
289
|
+
public virtual string TempFolderPath
|
|
290
|
+
{
|
|
291
|
+
get { return _tempFolderPath; }
|
|
292
|
+
set
|
|
293
|
+
{
|
|
294
|
+
if (string.IsNullOrEmpty(value))
|
|
295
|
+
{
|
|
296
|
+
_tempFolderPath = Path.GetTempPath();
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
// create the directory if it does not exist
|
|
301
|
+
if (!Directory.Exists(value))
|
|
302
|
+
{
|
|
303
|
+
Directory.CreateDirectory(value);
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
// check if the path contains directory separator at the end
|
|
307
|
+
if (value[value.Length - 1] == Path.DirectorySeparatorChar)
|
|
308
|
+
{
|
|
309
|
+
_tempFolderPath = value;
|
|
310
|
+
}
|
|
311
|
+
else
|
|
312
|
+
{
|
|
313
|
+
_tempFolderPath = value + Path.DirectorySeparatorChar;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/// <summary>
|
|
319
|
+
/// Gets or sets the date time format used when serializing in the ApiClient
|
|
320
|
+
/// By default, it's set to ISO 8601 - "o", for others see:
|
|
321
|
+
/// https://msdn.microsoft.com/en-us/library/az4se3k1(v=vs.110).aspx
|
|
322
|
+
/// and https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx
|
|
323
|
+
/// No validation is done to ensure that the string you're providing is valid
|
|
324
|
+
/// </summary>
|
|
325
|
+
/// <value>The DateTimeFormat string</value>
|
|
326
|
+
public virtual string DateTimeFormat
|
|
327
|
+
{
|
|
328
|
+
get { return _dateTimeFormat; }
|
|
329
|
+
set
|
|
330
|
+
{
|
|
331
|
+
if (string.IsNullOrEmpty(value))
|
|
332
|
+
{
|
|
333
|
+
// Never allow a blank or null string, go back to the default
|
|
334
|
+
_dateTimeFormat = ISO8601_DATETIME_FORMAT;
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Caution, no validation when you choose date time format other than ISO 8601
|
|
339
|
+
// Take a look at the above links
|
|
340
|
+
_dateTimeFormat = value;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/// <summary>
|
|
345
|
+
/// Gets or sets the prefix (e.g. Token) of the API key based on the authentication name.
|
|
346
|
+
///
|
|
347
|
+
/// Whatever you set here will be prepended to the value defined in AddApiKey.
|
|
348
|
+
///
|
|
349
|
+
/// An example invocation here might be:
|
|
350
|
+
/// <example>
|
|
351
|
+
/// ApiKeyPrefix["Authorization"] = "Bearer";
|
|
352
|
+
/// </example>
|
|
353
|
+
/// … where ApiKey["Authorization"] would then be used to set the value of your bearer token.
|
|
354
|
+
///
|
|
355
|
+
/// <remarks>
|
|
356
|
+
/// OAuth2 workflows should set tokens via AccessToken.
|
|
357
|
+
/// </remarks>
|
|
358
|
+
/// </summary>
|
|
359
|
+
/// <value>The prefix of the API key.</value>
|
|
360
|
+
public virtual IDictionary<string, string> ApiKeyPrefix
|
|
361
|
+
{
|
|
362
|
+
get { return _apiKeyPrefix; }
|
|
363
|
+
set
|
|
364
|
+
{
|
|
365
|
+
if (value == null)
|
|
366
|
+
{
|
|
367
|
+
throw new InvalidOperationException("ApiKeyPrefix collection may not be null.");
|
|
368
|
+
}
|
|
369
|
+
_apiKeyPrefix = value;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
/// <summary>
|
|
374
|
+
/// Gets or sets the API key based on the authentication name.
|
|
375
|
+
/// </summary>
|
|
376
|
+
/// <value>The API key.</value>
|
|
377
|
+
public virtual IDictionary<string, string> ApiKey
|
|
378
|
+
{
|
|
379
|
+
get { return _apiKey; }
|
|
380
|
+
set
|
|
381
|
+
{
|
|
382
|
+
if (value == null)
|
|
383
|
+
{
|
|
384
|
+
throw new InvalidOperationException("ApiKey collection may not be null.");
|
|
385
|
+
}
|
|
386
|
+
_apiKey = value;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
/// <summary>
|
|
391
|
+
/// Gets or sets the servers.
|
|
392
|
+
/// </summary>
|
|
393
|
+
/// <value>The servers.</value>
|
|
394
|
+
public virtual IList<IReadOnlyDictionary<string, object>> Servers
|
|
395
|
+
{
|
|
396
|
+
get { return _servers; }
|
|
397
|
+
set
|
|
398
|
+
{
|
|
399
|
+
if (value == null)
|
|
400
|
+
{
|
|
401
|
+
throw new InvalidOperationException("Servers may not be null.");
|
|
402
|
+
}
|
|
403
|
+
_servers = value;
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/// <summary>
|
|
408
|
+
/// Gets or sets the operation servers.
|
|
409
|
+
/// </summary>
|
|
410
|
+
/// <value>The operation servers.</value>
|
|
411
|
+
public virtual IReadOnlyDictionary<
|
|
412
|
+
string,
|
|
413
|
+
List<IReadOnlyDictionary<string, object>>
|
|
414
|
+
> OperationServers
|
|
415
|
+
{
|
|
416
|
+
get { return _operationServers; }
|
|
417
|
+
set
|
|
418
|
+
{
|
|
419
|
+
if (value == null)
|
|
420
|
+
{
|
|
421
|
+
throw new InvalidOperationException("Operation servers may not be null.");
|
|
422
|
+
}
|
|
423
|
+
_operationServers = value;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/// <summary>
|
|
428
|
+
/// Returns URL based on server settings without providing values
|
|
429
|
+
/// for the variables
|
|
430
|
+
/// </summary>
|
|
431
|
+
/// <param name="index">Array index of the server settings.</param>
|
|
432
|
+
/// <return>The server URL.</return>
|
|
433
|
+
public string GetServerUrl(int index)
|
|
434
|
+
{
|
|
435
|
+
return GetServerUrl(Servers, index, null);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
/// <summary>
|
|
439
|
+
/// Returns URL based on server settings.
|
|
440
|
+
/// </summary>
|
|
441
|
+
/// <param name="index">Array index of the server settings.</param>
|
|
442
|
+
/// <param name="inputVariables">Dictionary of the variables and the corresponding values.</param>
|
|
443
|
+
/// <return>The server URL.</return>
|
|
444
|
+
public string GetServerUrl(int index, Dictionary<string, string> inputVariables)
|
|
445
|
+
{
|
|
446
|
+
return GetServerUrl(Servers, index, inputVariables);
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
/// <summary>
|
|
450
|
+
/// Returns URL based on operation server settings.
|
|
451
|
+
/// </summary>
|
|
452
|
+
/// <param name="operation">Operation associated with the request path.</param>
|
|
453
|
+
/// <param name="index">Array index of the server settings.</param>
|
|
454
|
+
/// <return>The operation server URL.</return>
|
|
455
|
+
public string GetOperationServerUrl(string operation, int index)
|
|
456
|
+
{
|
|
457
|
+
return GetOperationServerUrl(operation, index, null);
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/// <summary>
|
|
461
|
+
/// Returns URL based on operation server settings.
|
|
462
|
+
/// </summary>
|
|
463
|
+
/// <param name="operation">Operation associated with the request path.</param>
|
|
464
|
+
/// <param name="index">Array index of the server settings.</param>
|
|
465
|
+
/// <param name="inputVariables">Dictionary of the variables and the corresponding values.</param>
|
|
466
|
+
/// <return>The operation server URL.</return>
|
|
467
|
+
public string GetOperationServerUrl(
|
|
468
|
+
string operation,
|
|
469
|
+
int index,
|
|
470
|
+
Dictionary<string, string> inputVariables
|
|
471
|
+
)
|
|
472
|
+
{
|
|
473
|
+
if (
|
|
474
|
+
operation != null
|
|
475
|
+
&& OperationServers.TryGetValue(operation, out var operationServer)
|
|
476
|
+
)
|
|
477
|
+
{
|
|
478
|
+
return GetServerUrl(operationServer, index, inputVariables);
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
return null;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
/// <summary>
|
|
485
|
+
/// Returns URL based on server settings.
|
|
486
|
+
/// </summary>
|
|
487
|
+
/// <param name="servers">Dictionary of server settings.</param>
|
|
488
|
+
/// <param name="index">Array index of the server settings.</param>
|
|
489
|
+
/// <param name="inputVariables">Dictionary of the variables and the corresponding values.</param>
|
|
490
|
+
/// <return>The server URL.</return>
|
|
491
|
+
private string GetServerUrl(
|
|
492
|
+
IList<IReadOnlyDictionary<string, object>> servers,
|
|
493
|
+
int index,
|
|
494
|
+
Dictionary<string, string> inputVariables
|
|
495
|
+
)
|
|
496
|
+
{
|
|
497
|
+
if (index < 0 || index >= servers.Count)
|
|
498
|
+
{
|
|
499
|
+
throw new InvalidOperationException(
|
|
500
|
+
$"Invalid index {index} when selecting the server. Must be less than {servers.Count}."
|
|
501
|
+
);
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
if (inputVariables == null)
|
|
505
|
+
{
|
|
506
|
+
inputVariables = new Dictionary<string, string>();
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
IReadOnlyDictionary<string, object> server = servers[index];
|
|
510
|
+
string url = (string)server["url"];
|
|
511
|
+
|
|
512
|
+
if (server.ContainsKey("variables"))
|
|
513
|
+
{
|
|
514
|
+
// go through each variable and assign a value
|
|
515
|
+
foreach (
|
|
516
|
+
KeyValuePair<string, object> variable in (IReadOnlyDictionary<string, object>)
|
|
517
|
+
server["variables"]
|
|
518
|
+
)
|
|
519
|
+
{
|
|
520
|
+
IReadOnlyDictionary<string, object> serverVariables =
|
|
521
|
+
(IReadOnlyDictionary<string, object>)(variable.Value);
|
|
522
|
+
|
|
523
|
+
if (inputVariables.ContainsKey(variable.Key))
|
|
524
|
+
{
|
|
525
|
+
if (
|
|
526
|
+
((List<string>)serverVariables["enum_values"]).Contains(
|
|
527
|
+
inputVariables[variable.Key]
|
|
528
|
+
)
|
|
529
|
+
)
|
|
530
|
+
{
|
|
531
|
+
url = url.Replace(
|
|
532
|
+
"{" + variable.Key + "}",
|
|
533
|
+
inputVariables[variable.Key]
|
|
534
|
+
);
|
|
535
|
+
}
|
|
536
|
+
else
|
|
537
|
+
{
|
|
538
|
+
throw new InvalidOperationException(
|
|
539
|
+
$"The variable `{variable.Key}` in the server URL has invalid value #{inputVariables[variable.Key]}. Must be {(List<string>)serverVariables["enum_values"]}"
|
|
540
|
+
);
|
|
541
|
+
}
|
|
542
|
+
}
|
|
543
|
+
else
|
|
544
|
+
{
|
|
545
|
+
// use default value
|
|
546
|
+
url = url.Replace(
|
|
547
|
+
"{" + variable.Key + "}",
|
|
548
|
+
(string)serverVariables["default_value"]
|
|
549
|
+
);
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
return url;
|
|
555
|
+
}
|
|
556
|
+
|
|
557
|
+
/// <summary>
|
|
558
|
+
/// Gets and Sets the RemoteCertificateValidationCallback
|
|
559
|
+
/// </summary>
|
|
560
|
+
public RemoteCertificateValidationCallback RemoteCertificateValidationCallback { get; set; }
|
|
561
|
+
|
|
562
|
+
#endregion Properties
|
|
563
|
+
|
|
564
|
+
#region Methods
|
|
565
|
+
|
|
566
|
+
/// <summary>
|
|
567
|
+
/// Returns a string with essential information for debugging.
|
|
568
|
+
/// </summary>
|
|
569
|
+
public static string ToDebugReport()
|
|
570
|
+
{
|
|
571
|
+
string report = "C# SDK (Seam) Debug Report:\n";
|
|
572
|
+
report += " OS: " + System.Environment.OSVersion + "\n";
|
|
573
|
+
report += " .NET Framework Version: " + System.Environment.Version + "\n";
|
|
574
|
+
report += " Version of the API: 1.0.0\n";
|
|
575
|
+
report += " SDK Package Version: 1.0.0\n";
|
|
576
|
+
|
|
577
|
+
return report;
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
/// <summary>
|
|
581
|
+
/// Add Api Key Header.
|
|
582
|
+
/// </summary>
|
|
583
|
+
/// <param name="key">Api Key name.</param>
|
|
584
|
+
/// <param name="value">Api Key value.</param>
|
|
585
|
+
/// <returns></returns>
|
|
586
|
+
public void AddApiKey(string key, string value)
|
|
587
|
+
{
|
|
588
|
+
ApiKey[key] = value;
|
|
589
|
+
}
|
|
590
|
+
|
|
591
|
+
/// <summary>
|
|
592
|
+
/// Sets the API key prefix.
|
|
593
|
+
/// </summary>
|
|
594
|
+
/// <param name="key">Api Key name.</param>
|
|
595
|
+
/// <param name="value">Api Key value.</param>
|
|
596
|
+
public void AddApiKeyPrefix(string key, string value)
|
|
597
|
+
{
|
|
598
|
+
ApiKeyPrefix[key] = value;
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
#endregion Methods
|
|
602
|
+
|
|
603
|
+
#region Static Members
|
|
604
|
+
/// <summary>
|
|
605
|
+
/// Merge configurations.
|
|
606
|
+
/// </summary>
|
|
607
|
+
/// <param name="first">First configuration.</param>
|
|
608
|
+
/// <param name="second">Second configuration.</param>
|
|
609
|
+
/// <return>Merged configuration.</return>
|
|
610
|
+
public static IReadableSeamRequestConfiguration MergeConfigurations(
|
|
611
|
+
IReadableSeamRequestConfiguration first,
|
|
612
|
+
IReadableSeamRequestConfiguration second
|
|
613
|
+
)
|
|
614
|
+
{
|
|
615
|
+
if (second == null)
|
|
616
|
+
return first ?? GlobalSeamRequestConfiguration.Instance;
|
|
617
|
+
|
|
618
|
+
// Dictionary<string, string> apiKey = first.ApiKey.ToDictionary(
|
|
619
|
+
// kvp => kvp.Key,
|
|
620
|
+
// kvp => kvp.Value
|
|
621
|
+
// );
|
|
622
|
+
// Dictionary<string, string> apiKeyPrefix = first.ApiKeyPrefix.ToDictionary(
|
|
623
|
+
// kvp => kvp.Key,
|
|
624
|
+
// kvp => kvp.Value
|
|
625
|
+
// );
|
|
626
|
+
Dictionary<string, string> defaultHeaders = first.DefaultHeaders.ToDictionary(
|
|
627
|
+
kvp => kvp.Key,
|
|
628
|
+
kvp => kvp.Value
|
|
629
|
+
);
|
|
630
|
+
|
|
631
|
+
// foreach (var kvp in second.ApiKey)
|
|
632
|
+
// apiKey[kvp.Key] = kvp.Value;
|
|
633
|
+
// foreach (var kvp in second.ApiKeyPrefix)
|
|
634
|
+
// apiKeyPrefix[kvp.Key] = kvp.Value;
|
|
635
|
+
foreach (var kvp in second.DefaultHeaders)
|
|
636
|
+
defaultHeaders[kvp.Key] = kvp.Value;
|
|
637
|
+
|
|
638
|
+
var config = new SeamRequestConfiguration
|
|
639
|
+
{
|
|
640
|
+
// ApiKey = apiKey,
|
|
641
|
+
// ApiKeyPrefix = apiKeyPrefix,
|
|
642
|
+
DefaultHeaders = defaultHeaders,
|
|
643
|
+
BasePath = second.BasePath ?? first.BasePath,
|
|
644
|
+
Timeout = second.Timeout,
|
|
645
|
+
Proxy = second.Proxy ?? first.Proxy,
|
|
646
|
+
UserAgent = second.UserAgent ?? first.UserAgent,
|
|
647
|
+
// Username = second.Username ?? first.Username,
|
|
648
|
+
// Password = second.Password ?? first.Password,
|
|
649
|
+
// ApiToken = second.ApiToken ?? first.ApiToken,
|
|
650
|
+
TempFolderPath = second.TempFolderPath ?? first.TempFolderPath,
|
|
651
|
+
DateTimeFormat = second.DateTimeFormat ?? first.DateTimeFormat,
|
|
652
|
+
ClientCertificates = second.ClientCertificates ?? first.ClientCertificates,
|
|
653
|
+
// UseDefaultCredentials = second.UseDefaultCredentials,
|
|
654
|
+
RemoteCertificateValidationCallback =
|
|
655
|
+
second.RemoteCertificateValidationCallback
|
|
656
|
+
?? first.RemoteCertificateValidationCallback,
|
|
657
|
+
};
|
|
658
|
+
return config;
|
|
659
|
+
}
|
|
660
|
+
#endregion Static Members
|
|
661
|
+
}
|
|
662
|
+
}
|