wesley-key-sdk 0.1.7 → 1.1.1

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.
Files changed (63) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +18 -110
  3. data/lib/{swagger_petstore → cypress_test_api}/api_helper.rb +2 -2
  4. data/lib/cypress_test_api/client.rb +47 -0
  5. data/lib/cypress_test_api/configuration.rb +103 -0
  6. data/lib/cypress_test_api/controllers/api_controller.rb +102 -0
  7. data/lib/{swagger_petstore → cypress_test_api}/controllers/base_controller.rb +2 -2
  8. data/lib/{swagger_petstore → cypress_test_api}/exceptions/api_exception.rb +2 -2
  9. data/lib/{swagger_petstore → cypress_test_api}/http/http_call_back.rb +2 -2
  10. data/lib/{swagger_petstore → cypress_test_api}/http/http_method_enum.rb +2 -2
  11. data/lib/{swagger_petstore → cypress_test_api}/http/http_request.rb +2 -2
  12. data/lib/{swagger_petstore → cypress_test_api}/http/http_response.rb +2 -2
  13. data/lib/cypress_test_api/http/proxy_settings.rb +13 -0
  14. data/lib/{swagger_petstore → cypress_test_api}/models/base_model.rb +2 -2
  15. data/lib/cypress_test_api/models/custom_enum.rb +26 -0
  16. data/lib/{swagger_petstore/models/category2.rb → cypress_test_api/models/deer.rb} +18 -21
  17. data/lib/cypress_test_api/models/item.rb +166 -0
  18. data/lib/{swagger_petstore/models/category.rb → cypress_test_api/models/item_response.rb} +19 -10
  19. data/lib/cypress_test_api/models/lion.rb +68 -0
  20. data/lib/cypress_test_api/models/message.rb +68 -0
  21. data/lib/{swagger_petstore/models/api_response.rb → cypress_test_api/models/message2.rb} +14 -24
  22. data/lib/cypress_test_api/models/multiple_arrays_request.rb +70 -0
  23. data/lib/cypress_test_api/models/nac_tag.rb +265 -0
  24. data/lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb +29 -0
  25. data/lib/cypress_test_api/models/response_http400.rb +62 -0
  26. data/lib/{swagger_petstore/models/tag.rb → cypress_test_api/models/response_http404.rb} +9 -18
  27. data/lib/cypress_test_api/models/status11_enum.rb +26 -0
  28. data/lib/cypress_test_api/models/status1_enum.rb +26 -0
  29. data/lib/cypress_test_api/models/status_enum.rb +26 -0
  30. data/lib/cypress_test_api/models/tokens_request.rb +60 -0
  31. data/lib/{swagger_petstore → cypress_test_api}/utilities/date_time_helper.rb +2 -2
  32. data/lib/{swagger_petstore → cypress_test_api}/utilities/file_wrapper.rb +2 -2
  33. data/lib/cypress_test_api.rb +55 -0
  34. data/test/controllers/controller_test_base.rb +11 -14
  35. data/test/controllers/test_api_controller.rb +40 -0
  36. data/test/http_response_catcher.rb +2 -2
  37. metadata +38 -46
  38. data/bin/console +0 -15
  39. data/lib/swagger_petstore/client.rb +0 -95
  40. data/lib/swagger_petstore/configuration.rb +0 -197
  41. data/lib/swagger_petstore/controllers/pet_controller.rb +0 -206
  42. data/lib/swagger_petstore/controllers/store_controller.rb +0 -94
  43. data/lib/swagger_petstore/controllers/user_controller.rb +0 -165
  44. data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +0 -64
  45. data/lib/swagger_petstore/http/auth/api_key.rb +0 -52
  46. data/lib/swagger_petstore/http/auth/http_basic.rb +0 -62
  47. data/lib/swagger_petstore/http/auth/petstore_auth.rb +0 -113
  48. data/lib/swagger_petstore/http/proxy_settings.rb +0 -22
  49. data/lib/swagger_petstore/models/content_type_enum.rb +0 -26
  50. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +0 -62
  51. data/lib/swagger_petstore/models/o_auth_scope_petstore_auth_enum.rb +0 -36
  52. data/lib/swagger_petstore/models/o_auth_token.rb +0 -96
  53. data/lib/swagger_petstore/models/order.rb +0 -120
  54. data/lib/swagger_petstore/models/pet.rb +0 -117
  55. data/lib/swagger_petstore/models/pet_request.rb +0 -117
  56. data/lib/swagger_petstore/models/status1_enum.rb +0 -40
  57. data/lib/swagger_petstore/models/status2_enum.rb +0 -40
  58. data/lib/swagger_petstore/models/status_enum.rb +0 -40
  59. data/lib/swagger_petstore/models/store_order_request.rb +0 -120
  60. data/lib/swagger_petstore/models/user.rb +0 -132
  61. data/lib/swagger_petstore/models/user_request.rb +0 -132
  62. data/lib/swagger_petstore.rb +0 -62
  63. data/test/controllers/test_store_controller.rb +0 -31
@@ -1,4 +1,4 @@
1
- # swagger_petstore
1
+ # cypress_test_api
2
2
  #
3
3
  # This file was automatically generated by APIMATIC v3.0
4
4
  # ( https://www.apimatic.io ).
@@ -8,25 +8,22 @@ require 'minitest/autorun'
8
8
  require 'minitest/hell'
9
9
  require 'minitest/pride'
10
10
  require 'minitest/proveit'
11
- require 'swagger_petstore'
11
+ require 'cypress_test_api'
12
12
  require_relative '../http_response_catcher'
13
13
 
14
14
  class ControllerTestBase < Minitest::Test
15
15
  parallelize_me!
16
- include SwaggerPetstore
16
+ include CypressTestApi
17
17
  include CoreLibrary
18
18
 
19
+ # Create configuration and set any test parameters
20
+ def create_configuration
21
+ Configuration.new(http_callback: HttpResponseCatcher.new)
22
+ end
23
+
19
24
  # Initializes the base test controller
20
25
  def setup_class
21
- @client = Client.from_env(
22
- http_basic_credentials: HttpBasicCredentials.new(username: 'test',
23
- passwprd: 'testPassword'),
24
- http_callback: HttpResponseCatcher.new
25
- )
26
-
27
- _config = @client.config
28
- petstore_auth_token = @client.petstore_auth.fetch_token()
29
- petstore_auth_credentials = _config.petstore_auth_credentials.clone_with(o_auth_token: petstore_auth_token)
30
- _config = _config.clone_with(petstore_auth_credentials: petstore_auth_credentials)
31
- @client = Client.new(config: _config)
32
26
  end
27
+ _config = create_configuration
28
+ @client = Client.new(config: _config)
29
+ end
33
30
  end
@@ -0,0 +1,40 @@
1
+ # cypress_test_api
2
+ #
3
+ # This file was automatically generated by APIMATIC v3.0
4
+ # ( https://www.apimatic.io ).
5
+
6
+ require_relative 'controller_test_base'
7
+
8
+ class APIControllerTest < ControllerTestBase
9
+ # Called only once for the class before any test has executed
10
+ def setup
11
+ setup_class
12
+ @controller = @client.client
13
+ @response_catcher = @controller.http_call_back
14
+ end
15
+
16
+ # Generates a new OAuth token with the specified scopes.
17
+ def test_create_o_auth_token
18
+ # Parameters for the API call
19
+ body = nil
20
+
21
+ # Perform the API call through the SDK function
22
+ @controller.create_o_auth_token(body: body)
23
+
24
+ # Test response code
25
+ assert_equal(201, @response_catcher.response.status_code)
26
+ end
27
+
28
+ # This endpoint accepts a complex structure with multiple arrays.
29
+ def test_test_endpointwith_arrays
30
+ # Parameters for the API call
31
+ body = nil
32
+
33
+ # Perform the API call through the SDK function
34
+ @controller.test_endpointwith_arrays(body: body)
35
+
36
+ # Test response code
37
+ assert_equal(200, @response_catcher.response.status_code)
38
+ end
39
+
40
+ end
@@ -1,9 +1,9 @@
1
- # swagger_petstore
1
+ # cypress_test_api
2
2
  #
3
3
  # This file was automatically generated by APIMATIC v3.0
4
4
  # ( https://www.apimatic.io ).
5
5
 
6
- class HttpResponseCatcher < SwaggerPetstore::HttpCallBack
6
+ class HttpResponseCatcher < CypressTestApi::HttpCallBack
7
7
  attr_reader :response
8
8
 
9
9
  def on_before_request(request)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wesley-key-sdk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.7
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenyon Jacobs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-11-28 00:00:00.000000000 Z
11
+ date: 2025-08-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: apimatic_core_interfaces
@@ -16,28 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.2.3
19
+ version: 0.2.2
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.2.3
26
+ version: 0.2.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: apimatic_core
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.3.20
33
+ version: 0.3.19
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.3.20
40
+ version: 0.3.19
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: apimatic_faraday_client_adapter
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -89,47 +89,39 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - LICENSE
91
91
  - README.md
92
- - bin/console
93
- - lib/swagger_petstore.rb
94
- - lib/swagger_petstore/api_helper.rb
95
- - lib/swagger_petstore/client.rb
96
- - lib/swagger_petstore/configuration.rb
97
- - lib/swagger_petstore/controllers/base_controller.rb
98
- - lib/swagger_petstore/controllers/pet_controller.rb
99
- - lib/swagger_petstore/controllers/store_controller.rb
100
- - lib/swagger_petstore/controllers/user_controller.rb
101
- - lib/swagger_petstore/exceptions/api_exception.rb
102
- - lib/swagger_petstore/exceptions/o_auth_provider_exception.rb
103
- - lib/swagger_petstore/http/auth/api_key.rb
104
- - lib/swagger_petstore/http/auth/http_basic.rb
105
- - lib/swagger_petstore/http/auth/petstore_auth.rb
106
- - lib/swagger_petstore/http/http_call_back.rb
107
- - lib/swagger_petstore/http/http_method_enum.rb
108
- - lib/swagger_petstore/http/http_request.rb
109
- - lib/swagger_petstore/http/http_response.rb
110
- - lib/swagger_petstore/http/proxy_settings.rb
111
- - lib/swagger_petstore/models/api_response.rb
112
- - lib/swagger_petstore/models/base_model.rb
113
- - lib/swagger_petstore/models/category.rb
114
- - lib/swagger_petstore/models/category2.rb
115
- - lib/swagger_petstore/models/content_type_enum.rb
116
- - lib/swagger_petstore/models/o_auth_provider_error_enum.rb
117
- - lib/swagger_petstore/models/o_auth_scope_petstore_auth_enum.rb
118
- - lib/swagger_petstore/models/o_auth_token.rb
119
- - lib/swagger_petstore/models/order.rb
120
- - lib/swagger_petstore/models/pet.rb
121
- - lib/swagger_petstore/models/pet_request.rb
122
- - lib/swagger_petstore/models/status1_enum.rb
123
- - lib/swagger_petstore/models/status2_enum.rb
124
- - lib/swagger_petstore/models/status_enum.rb
125
- - lib/swagger_petstore/models/store_order_request.rb
126
- - lib/swagger_petstore/models/tag.rb
127
- - lib/swagger_petstore/models/user.rb
128
- - lib/swagger_petstore/models/user_request.rb
129
- - lib/swagger_petstore/utilities/date_time_helper.rb
130
- - lib/swagger_petstore/utilities/file_wrapper.rb
92
+ - lib/cypress_test_api.rb
93
+ - lib/cypress_test_api/api_helper.rb
94
+ - lib/cypress_test_api/client.rb
95
+ - lib/cypress_test_api/configuration.rb
96
+ - lib/cypress_test_api/controllers/api_controller.rb
97
+ - lib/cypress_test_api/controllers/base_controller.rb
98
+ - lib/cypress_test_api/exceptions/api_exception.rb
99
+ - lib/cypress_test_api/http/http_call_back.rb
100
+ - lib/cypress_test_api/http/http_method_enum.rb
101
+ - lib/cypress_test_api/http/http_request.rb
102
+ - lib/cypress_test_api/http/http_response.rb
103
+ - lib/cypress_test_api/http/proxy_settings.rb
104
+ - lib/cypress_test_api/models/base_model.rb
105
+ - lib/cypress_test_api/models/custom_enum.rb
106
+ - lib/cypress_test_api/models/deer.rb
107
+ - lib/cypress_test_api/models/item.rb
108
+ - lib/cypress_test_api/models/item_response.rb
109
+ - lib/cypress_test_api/models/lion.rb
110
+ - lib/cypress_test_api/models/message.rb
111
+ - lib/cypress_test_api/models/message2.rb
112
+ - lib/cypress_test_api/models/multiple_arrays_request.rb
113
+ - lib/cypress_test_api/models/nac_tag.rb
114
+ - lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb
115
+ - lib/cypress_test_api/models/response_http400.rb
116
+ - lib/cypress_test_api/models/response_http404.rb
117
+ - lib/cypress_test_api/models/status11_enum.rb
118
+ - lib/cypress_test_api/models/status1_enum.rb
119
+ - lib/cypress_test_api/models/status_enum.rb
120
+ - lib/cypress_test_api/models/tokens_request.rb
121
+ - lib/cypress_test_api/utilities/date_time_helper.rb
122
+ - lib/cypress_test_api/utilities/file_wrapper.rb
131
123
  - test/controllers/controller_test_base.rb
132
- - test/controllers/test_store_controller.rb
124
+ - test/controllers/test_api_controller.rb
133
125
  - test/http_response_catcher.rb
134
126
  homepage: https://www.halefokodaqiby.com
135
127
  licenses:
data/bin/console DELETED
@@ -1,15 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # Load the lib folder into Ruby's load path
4
- $LOAD_PATH.unshift(File.expand_path('../lib', __dir__))
5
-
6
- # Require the gem
7
- require 'swagger_petstore'
8
-
9
- puts 'SwaggerPetstore SDK loaded!'
10
- puts 'You can now create a client with: client = SwaggerPetstore::Client.new'
11
- puts 'Or use from_env: client = SwaggerPetstore::Client.from_env'
12
-
13
- # Start an interactive IRB session
14
- require 'irb'
15
- IRB.start
@@ -1,95 +0,0 @@
1
- # swagger_petstore
2
- #
3
- # This file was automatically generated by APIMATIC v3.0
4
- # ( https://www.apimatic.io ).
5
-
6
- module SwaggerPetstore
7
- # swagger_petstore client class.
8
- class Client
9
- include CoreLibrary
10
- attr_reader :config, :auth_managers
11
-
12
- def user_agent_detail
13
- config.user_agent_detail
14
- end
15
-
16
- # Returns the configured authentication petstore_auth instance.
17
- def petstore_auth
18
- @auth_managers['petstore_auth']
19
- end
20
-
21
- # Access to pet controller.
22
- # @return [PetController] Returns the controller instance.
23
- def pet
24
- @pet ||= PetController.new @global_configuration
25
- end
26
-
27
- # Access to store controller.
28
- # @return [StoreController] Returns the controller instance.
29
- def store
30
- @store ||= StoreController.new @global_configuration
31
- end
32
-
33
- # Access to user controller.
34
- # @return [UserController] Returns the controller instance.
35
- def user
36
- @user ||= UserController.new @global_configuration
37
- end
38
-
39
- def initialize(
40
- connection: nil, adapter: :net_http_persistent, timeout: 60,
41
- max_retries: 0, retry_interval: 1, backoff_factor: 2,
42
- retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
43
- retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
44
- environment: Environment::PRODUCTION, api_key_credentials: nil,
45
- http_basic_credentials: nil, petstore_auth_credentials: nil,
46
- test_header: 'TestHeaderDefaultValue', config: nil
47
- )
48
- @config = if config.nil?
49
- Configuration.new(
50
- connection: connection, adapter: adapter, timeout: timeout,
51
- max_retries: max_retries, retry_interval: retry_interval,
52
- backoff_factor: backoff_factor,
53
- retry_statuses: retry_statuses,
54
- retry_methods: retry_methods, http_callback: http_callback,
55
- proxy_settings: proxy_settings, environment: environment,
56
- api_key_credentials: api_key_credentials,
57
- http_basic_credentials: http_basic_credentials,
58
- petstore_auth_credentials: petstore_auth_credentials,
59
- test_header: test_header
60
- )
61
- else
62
- config
63
- end
64
-
65
- @global_configuration = GlobalConfiguration.new(client_configuration: @config)
66
- .base_uri_executor(@config.method(:get_base_uri))
67
- .global_errors(BaseController::GLOBAL_ERRORS)
68
- .user_agent(BaseController.user_agent)
69
- .global_header('TestHeader', @config.test_header)
70
-
71
- initialize_auth_managers(@global_configuration)
72
- @global_configuration = @global_configuration.auth_managers(@auth_managers)
73
- end
74
-
75
- # Initializes the auth managers hash used for authenticating API calls.
76
- # @param [GlobalConfiguration] global_config The global configuration of the SDK)
77
- def initialize_auth_managers(global_config)
78
- @auth_managers = {}
79
- http_client_config = global_config.client_configuration
80
- %w[api_key httpBasic petstore_auth].each { |auth| @auth_managers[auth] = nil }
81
- @auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials)
82
- @auth_managers['httpBasic'] = HttpBasic.new(http_client_config.http_basic_credentials)
83
- @auth_managers['petstore_auth'] = PetstoreAuth.new(
84
- http_client_config.petstore_auth_credentials, global_config
85
- )
86
- end
87
-
88
- # Creates a client directly from environment variables.
89
- def self.from_env(**overrides)
90
- default_config = Configuration.build_default_config_from_env
91
- new_config = default_config.clone_with(**overrides)
92
- new(config: new_config)
93
- end
94
- end
95
- end
@@ -1,197 +0,0 @@
1
- # swagger_petstore
2
- #
3
- # This file was automatically generated by APIMATIC v3.0
4
- # ( https://www.apimatic.io ).
5
-
6
- module SwaggerPetstore
7
- # An enum for SDK environments.
8
- class Environment
9
- ENVIRONMENT = [
10
- PRODUCTION = 'production'.freeze,
11
- ENVIRONMENT2 = 'environment2'.freeze,
12
- ENVIRONMENT3 = 'environment3'.freeze
13
- ].freeze
14
-
15
- # Converts a string or symbol into a valid Environment constant.
16
- def self.from_value(value, default_value = PRODUCTION)
17
- return default_value if value.nil?
18
-
19
- str = value.to_s.strip.downcase
20
- case str
21
- when 'production' then PRODUCTION
22
- when 'environment2' then ENVIRONMENT2
23
- when 'environment3' then ENVIRONMENT3
24
-
25
- else
26
- warn "[Environment] Unknown environment '#{value}', falling back to #{default_value} "
27
- default_value
28
- end
29
- end
30
- end
31
-
32
- # An enum for API servers.
33
- class Server
34
- SERVER = [
35
- DEFAULT = 'default'.freeze
36
- ].freeze
37
-
38
- # Converts a string or symbol into a valid Server constant.
39
- def self.from_value(value, default_value = DEFAULT)
40
- return default_value if value.nil?
41
-
42
- default_value
43
- end
44
- end
45
-
46
- # All configuration including auth info and base URI for the API access
47
- # are configured in this class.
48
- class Configuration < CoreLibrary::HttpClientConfiguration
49
- # The attribute readers for properties.
50
- attr_reader :environment, :api_key_credentials, :http_basic_credentials,
51
- :petstore_auth_credentials, :test_header
52
-
53
- class << self
54
- attr_reader :environments
55
- end
56
-
57
- def initialize(
58
- connection: nil, adapter: :net_http_persistent, timeout: 60,
59
- max_retries: 0, retry_interval: 1, backoff_factor: 2,
60
- retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
61
- retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
62
- environment: Environment::PRODUCTION, api_key_credentials: nil,
63
- http_basic_credentials: nil, petstore_auth_credentials: nil,
64
- test_header: 'TestHeaderDefaultValue'
65
- )
66
- super connection: connection, adapter: adapter, timeout: timeout,
67
- max_retries: max_retries, retry_interval: retry_interval,
68
- backoff_factor: backoff_factor, retry_statuses: retry_statuses,
69
- retry_methods: retry_methods, http_callback: http_callback,
70
- proxy_settings: proxy_settings
71
-
72
- # Current API environment
73
- @environment = String(environment)
74
-
75
- # The object holding Custom Header Signature credentials
76
- @api_key_credentials = api_key_credentials
77
-
78
- # The object holding Basic Authentication credentials
79
- @http_basic_credentials = http_basic_credentials
80
-
81
- # The object holding OAuth 2 Implicit Grant credentials
82
- @petstore_auth_credentials = petstore_auth_credentials
83
-
84
- # This is a test header
85
- @test_header = test_header
86
-
87
- # The Http Client to use for making requests.
88
- set_http_client CoreLibrary::FaradayClient.new(self)
89
- end
90
-
91
- def clone_with(connection: nil, adapter: nil, timeout: nil,
92
- max_retries: nil, retry_interval: nil, backoff_factor: nil,
93
- retry_statuses: nil, retry_methods: nil, http_callback: nil,
94
- proxy_settings: nil, environment: nil,
95
- api_key_credentials: nil, http_basic_credentials: nil,
96
- petstore_auth_credentials: nil, test_header: nil)
97
- connection ||= self.connection
98
- adapter ||= self.adapter
99
- timeout ||= self.timeout
100
- max_retries ||= self.max_retries
101
- retry_interval ||= self.retry_interval
102
- backoff_factor ||= self.backoff_factor
103
- retry_statuses ||= self.retry_statuses
104
- retry_methods ||= self.retry_methods
105
- http_callback ||= self.http_callback
106
- proxy_settings ||= self.proxy_settings
107
- environment ||= self.environment
108
- api_key_credentials ||= self.api_key_credentials
109
- http_basic_credentials ||= self.http_basic_credentials
110
- petstore_auth_credentials ||= self.petstore_auth_credentials
111
- test_header ||= self.test_header
112
-
113
- Configuration.new(connection: connection, adapter: adapter,
114
- timeout: timeout, max_retries: max_retries,
115
- retry_interval: retry_interval,
116
- backoff_factor: backoff_factor,
117
- retry_statuses: retry_statuses,
118
- retry_methods: retry_methods,
119
- http_callback: http_callback,
120
- proxy_settings: proxy_settings,
121
- environment: environment,
122
- api_key_credentials: api_key_credentials,
123
- http_basic_credentials: http_basic_credentials,
124
- petstore_auth_credentials: petstore_auth_credentials,
125
- test_header: test_header)
126
- end
127
-
128
-
129
- # All the environments the SDK can run in.
130
- ENVIRONMENTS = {
131
- Environment::PRODUCTION => {
132
- Server::DEFAULT => 'https://petstore.swagger.io/v2'
133
- },
134
- Environment::ENVIRONMENT2 => {
135
- Server::DEFAULT => 'http://petstore.swagger.io/v2'
136
- },
137
- Environment::ENVIRONMENT3 => {
138
- Server::DEFAULT => 'https://petstore.swagger.io/oauth'
139
- }
140
- }.freeze
141
-
142
- # Generates the appropriate base URI for the environment and the server.
143
- # @param [Configuration::Server] server The server enum for which the base URI is
144
- # required.
145
- # @return [String] The base URI.
146
- def get_base_uri(server = Server::DEFAULT)
147
- ENVIRONMENTS[environment][server].clone
148
- end
149
-
150
- # Builds a Configuration instance using environment variables.
151
- def self.build_default_config_from_env
152
- # === Core environment ===
153
- environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
154
- test_header = ENV.fetch('TEST_HEADER', 'TestHeaderDefaultValue')
155
- timeout = (ENV['TIMEOUT'] || 60).to_f
156
- max_retries = (ENV['MAX_RETRIES'] || 0).to_i
157
- retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
158
- backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
159
- retry_statuses = ENV.fetch('RETRY_STATUSES',
160
- '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
161
- .split(',')
162
- .map(&:strip)
163
- .map do |item|
164
- item.match?(/\A\d+\z/) ? item.to_i : item.downcase
165
- end
166
- retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
167
- .split(',')
168
- .map(&:strip)
169
- .map do |item|
170
- item.match?(/\A\d+\z/) ? item.to_i : item.downcase
171
- end
172
-
173
- # === Authentication credentials ===
174
- api_key_credentials = ApiKeyCredentials.from_env
175
- http_basic_credentials = HttpBasicCredentials.from_env
176
- petstore_auth_credentials = PetstoreAuthCredentials.from_env
177
-
178
- # === Proxy settings ===
179
- proxy_settings = ProxySettings.from_env
180
-
181
- Configuration.new(
182
- environment: environment,
183
- test_header: test_header,
184
- timeout: timeout,
185
- max_retries: max_retries,
186
- retry_interval: retry_interval,
187
- backoff_factor: backoff_factor,
188
- retry_statuses: retry_statuses,
189
- retry_methods: retry_methods,
190
- api_key_credentials: api_key_credentials,
191
- http_basic_credentials: http_basic_credentials,
192
- petstore_auth_credentials: petstore_auth_credentials,
193
- proxy_settings: proxy_settings
194
- )
195
- end
196
- end
197
- end