package-test-ruby 1.0.3

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 (43) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +28 -0
  3. data/README.md +174 -0
  4. data/bin/console +15 -0
  5. data/lib/swagger_petstore_open_api30/api_helper.rb +10 -0
  6. data/lib/swagger_petstore_open_api30/client.rb +90 -0
  7. data/lib/swagger_petstore_open_api30/configuration.rb +173 -0
  8. data/lib/swagger_petstore_open_api30/controllers/base_controller.rb +60 -0
  9. data/lib/swagger_petstore_open_api30/controllers/pet_controller.rb +271 -0
  10. data/lib/swagger_petstore_open_api30/controllers/store_controller.rb +125 -0
  11. data/lib/swagger_petstore_open_api30/controllers/user_controller.rb +223 -0
  12. data/lib/swagger_petstore_open_api30/exceptions/api_exception.rb +21 -0
  13. data/lib/swagger_petstore_open_api30/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/swagger_petstore_open_api30/http/auth/api_key.rb +52 -0
  15. data/lib/swagger_petstore_open_api30/http/auth/petstore_auth.rb +113 -0
  16. data/lib/swagger_petstore_open_api30/http/http_call_back.rb +10 -0
  17. data/lib/swagger_petstore_open_api30/http/http_method_enum.rb +10 -0
  18. data/lib/swagger_petstore_open_api30/http/http_request.rb +10 -0
  19. data/lib/swagger_petstore_open_api30/http/http_response.rb +10 -0
  20. data/lib/swagger_petstore_open_api30/http/proxy_settings.rb +22 -0
  21. data/lib/swagger_petstore_open_api30/models/api_response.rb +101 -0
  22. data/lib/swagger_petstore_open_api30/models/base_model.rb +110 -0
  23. data/lib/swagger_petstore_open_api30/models/category.rb +88 -0
  24. data/lib/swagger_petstore_open_api30/models/o_auth_provider_error_enum.rb +62 -0
  25. data/lib/swagger_petstore_open_api30/models/o_auth_scope_petstore_auth_enum.rb +36 -0
  26. data/lib/swagger_petstore_open_api30/models/o_auth_token.rb +125 -0
  27. data/lib/swagger_petstore_open_api30/models/order.rb +151 -0
  28. data/lib/swagger_petstore_open_api30/models/pet.rb +151 -0
  29. data/lib/swagger_petstore_open_api30/models/status1_enum.rb +40 -0
  30. data/lib/swagger_petstore_open_api30/models/status2_enum.rb +40 -0
  31. data/lib/swagger_petstore_open_api30/models/status_enum.rb +40 -0
  32. data/lib/swagger_petstore_open_api30/models/tag.rb +88 -0
  33. data/lib/swagger_petstore_open_api30/models/user.rb +167 -0
  34. data/lib/swagger_petstore_open_api30/utilities/date_time_helper.rb +11 -0
  35. data/lib/swagger_petstore_open_api30/utilities/file_wrapper.rb +28 -0
  36. data/lib/swagger_petstore_open_api30/utilities/xml_utilities.rb +12 -0
  37. data/lib/swagger_petstore_open_api30.rb +59 -0
  38. data/test/controllers/controller_test_base.rb +28 -0
  39. data/test/controllers/test_pet_controller.rb +50 -0
  40. data/test/controllers/test_store_controller.rb +55 -0
  41. data/test/controllers/test_user_controller.rb +156 -0
  42. data/test/http_response_catcher.rb +19 -0
  43. metadata +153 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: efc95ec9da0ba4eabb8f6903d8815972ea50dcb6d5df7844377c35e6f022ac12
4
+ data.tar.gz: 4e566f11417f12b1ddd0f5842dbbae5aa7ceae0734105867de20871267875bc2
5
+ SHA512:
6
+ metadata.gz: ed23ed2d45c50af8a3ec0007a40868334d4fdaced92f6359d1c956c2e99a20db2ea0f2081147892cbef83b066029371c183a00fe01170f4e210da6069f6c6188
7
+ data.tar.gz: f1e1043f212a6f49724e3bf7ce8f3102a59f00ac91b6a63cc6757c234b3335e08965d90e603f6a1f44da4adc6fea44466125708ce003e1c3eb11eb0cf165e6fa
data/LICENSE ADDED
@@ -0,0 +1,28 @@
1
+ License:
2
+ ========
3
+ The MIT License (MIT)
4
+ http://opensource.org/licenses/MIT
5
+
6
+ Copyright (c) 2014 - 2026 APIMATIC Limited
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+
26
+ Trade Mark:
27
+ ==========
28
+ APIMATIC is a trade mark for APIMATIC Limited
data/README.md ADDED
@@ -0,0 +1,174 @@
1
+
2
+ # Getting Started with Swagger Petstore - OpenAPI 3.0
3
+
4
+ ## Introduction
5
+
6
+ This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about
7
+ Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach!
8
+ You can now help us improve the API whether it's by making changes to the definition itself or to the code.
9
+ That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
10
+
11
+ Some useful links:
12
+
13
+ - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore)
14
+ - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
15
+
16
+ Find out more about Swagger: [https://swagger.io](https://swagger.io)
17
+
18
+ ## Install the Package
19
+
20
+ Install the gem from the command line:
21
+
22
+ ```bash
23
+ gem install package-test-ruby -v 1.0.3
24
+ ```
25
+
26
+ Or add the gem to your Gemfile and run `bundle`:
27
+
28
+ ```ruby
29
+ gem 'package-test-ruby', '1.0.3'
30
+ ```
31
+
32
+ For additional gem details, see the [RubyGems page for the package-test-ruby gem](https://rubygems.org/gems/package-test-ruby/versions/1.0.3).
33
+
34
+ ## IRB Console Usage
35
+
36
+ You can explore the SDK interactively using IRB in two ways
37
+
38
+ ### 1. Use IRB with Installed Gem
39
+
40
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
41
+
42
+ ```bash
43
+ irb
44
+ ```
45
+
46
+ Now you can load the SDK in the IRB
47
+
48
+ ```ruby
49
+ require 'swagger_petstore_open_api30'
50
+ include SwaggerPetstoreOpenApi30
51
+ ```
52
+
53
+ ### 2. Use IRB within SDK
54
+
55
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
56
+
57
+ ```
58
+ cd path/to/swagger_petstore_open_api30
59
+ ```
60
+
61
+ Now you can start the preconfigured irb console by running the following command
62
+
63
+ ```bash
64
+ ruby bin/console
65
+ ```
66
+
67
+ **_Note:_** This automatically loads the SDK from lib/
68
+
69
+ ## Test the SDK
70
+
71
+ To run the tests, navigate to the root directory of the SDK in your terminal and execute the following command:
72
+
73
+ ```
74
+ rake
75
+ ```
76
+
77
+ ## Initialize the API Client
78
+
79
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/client.md)
80
+
81
+ The following parameters are configurable for the API Client:
82
+
83
+ | Parameter | Type | Description |
84
+ | --- | --- | --- |
85
+ | environment | [`Environment`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/README.md#environments) | The API environment. <br> **Default: `Environment.PRODUCTION`** |
86
+ | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
87
+ | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
88
+ | timeout | `Float` | The value to use for connection timeout. <br> **Default: 60** |
89
+ | max_retries | `Integer` | The number of times to retry an endpoint call if it fails. <br> **Default: 0** |
90
+ | retry_interval | `Float` | Pause in seconds between retries. <br> **Default: 1** |
91
+ | backoff_factor | `Float` | The amount to multiply each successive retry's interval amount by in order to provide backoff. <br> **Default: 2** |
92
+ | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
93
+ | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
94
+ | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
95
+ | proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
96
+ | petstore_auth_credentials | [`PetstoreAuthCredentials`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/auth/oauth-2-implicit-grant.md) | The credential object for OAuth 2 Implicit Grant |
97
+ | api_key_credentials | [`ApiKeyCredentials`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/auth/custom-header-signature.md) | The credential object for Custom Header Signature |
98
+
99
+ The API client can be initialized as follows:
100
+
101
+ ### Code-Based Client Initialization
102
+
103
+ ```ruby
104
+ require 'swagger_petstore_open_api30'
105
+ include SwaggerPetstoreOpenApi30
106
+
107
+ client = Client.new(
108
+ petstore_auth_credentials: PetstoreAuthCredentials.new(
109
+ o_auth_client_id: 'OAuthClientId',
110
+ o_auth_redirect_uri: 'OAuthRedirectUri',
111
+ o_auth_scopes: [
112
+ OAuthScopePetstoreAuthEnum::WRITEPETS,
113
+ OAuthScopePetstoreAuthEnum::READPETS
114
+ ]
115
+ ),
116
+ api_key_credentials: ApiKeyCredentials.new(
117
+ api_key: 'api_key'
118
+ ),
119
+ environment: Environment::PRODUCTION
120
+ )
121
+ ```
122
+
123
+ ### Environment-Based Client Initialization
124
+
125
+ ```ruby
126
+ require 'swagger_petstore_open_api30'
127
+ include SwaggerPetstoreOpenApi30
128
+
129
+ # Create client from environment
130
+ client = Client.from_env
131
+ ```
132
+
133
+ See the [`Environment-Based Client Initialization`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/environment-based-client-initialization.md) section for details.
134
+
135
+ ## Environments
136
+
137
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
138
+
139
+ ### Fields
140
+
141
+ | Name | Description |
142
+ | --- | --- |
143
+ | PRODUCTION | **Default** |
144
+
145
+ ## Authorization
146
+
147
+ This API uses the following authentication schemes.
148
+
149
+ * [`petstore_auth (OAuth 2 Implicit Grant)`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/auth/oauth-2-implicit-grant.md)
150
+ * [`api_key (Custom Header Signature)`](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/auth/custom-header-signature.md)
151
+
152
+ ## List of APIs
153
+
154
+ * [Pet](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/controllers/pet.md)
155
+ * [Store](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/controllers/store.md)
156
+ * [User](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/controllers/user.md)
157
+
158
+ ## SDK Infrastructure
159
+
160
+ ### Configuration
161
+
162
+ * [ProxySettings](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/proxy-settings.md)
163
+ * [Environment-Based Client Initialization](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/environment-based-client-initialization.md)
164
+
165
+ ### HTTP
166
+
167
+ * [HttpResponse](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/http-response.md)
168
+ * [HttpRequest](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/http-request.md)
169
+
170
+ ### Utilities
171
+
172
+ * [ApiHelper](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/api-helper.md)
173
+ * [DateTimeHelper](https://www.github.com/ZahraN444/rubypack222/tree/1.0.3/doc/date-time-helper.md)
174
+
data/bin/console ADDED
@@ -0,0 +1,15 @@
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_open_api30'
8
+
9
+ puts 'SwaggerPetstoreOpenApi30 SDK loaded!'
10
+ puts 'You can now create a client with: client = SwaggerPetstoreOpenApi30::Client.new'
11
+ puts 'Or use from_env: client = SwaggerPetstoreOpenApi30::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -0,0 +1,10 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # API utility class
8
+ class APIHelper < CoreLibrary::ApiHelper
9
+ end
10
+ end
@@ -0,0 +1,90 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # swagger_petstore_open_api30 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, petstore_auth_credentials: nil,
45
+ api_key_credentials: nil, config: nil
46
+ )
47
+ @config = if config.nil?
48
+ Configuration.new(
49
+ connection: connection, adapter: adapter, timeout: timeout,
50
+ max_retries: max_retries, retry_interval: retry_interval,
51
+ backoff_factor: backoff_factor,
52
+ retry_statuses: retry_statuses,
53
+ retry_methods: retry_methods, http_callback: http_callback,
54
+ proxy_settings: proxy_settings, environment: environment,
55
+ petstore_auth_credentials: petstore_auth_credentials,
56
+ api_key_credentials: api_key_credentials
57
+ )
58
+ else
59
+ config
60
+ end
61
+
62
+ @global_configuration = GlobalConfiguration.new(client_configuration: @config)
63
+ .base_uri_executor(@config.method(:get_base_uri))
64
+ .global_errors(BaseController::GLOBAL_ERRORS)
65
+ .user_agent(BaseController.user_agent)
66
+
67
+ initialize_auth_managers(@global_configuration)
68
+ @global_configuration = @global_configuration.auth_managers(@auth_managers)
69
+ end
70
+
71
+ # Initializes the auth managers hash used for authenticating API calls.
72
+ # @param [GlobalConfiguration] global_config The global configuration of the SDK)
73
+ def initialize_auth_managers(global_config)
74
+ @auth_managers = {}
75
+ http_client_config = global_config.client_configuration
76
+ %w[petstore_auth api_key].each { |auth| @auth_managers[auth] = nil }
77
+ @auth_managers['petstore_auth'] = PetstoreAuth.new(
78
+ http_client_config.petstore_auth_credentials, global_config
79
+ )
80
+ @auth_managers['api_key'] = ApiKey.new(http_client_config.api_key_credentials)
81
+ end
82
+
83
+ # Creates a client directly from environment variables.
84
+ def self.from_env(**overrides)
85
+ default_config = Configuration.build_default_config_from_env
86
+ new_config = default_config.clone_with(**overrides)
87
+ new(config: new_config)
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,173 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # An enum for SDK environments.
8
+ class Environment
9
+ ENVIRONMENT = [
10
+ PRODUCTION = 'production'.freeze
11
+ ].freeze
12
+
13
+ # Converts a string or symbol into a valid Environment constant.
14
+ def self.from_value(value, default_value = PRODUCTION)
15
+ return default_value if value.nil?
16
+
17
+ default_value
18
+ end
19
+ end
20
+
21
+ # An enum for API servers.
22
+ class Server
23
+ SERVER = [
24
+ DEFAULT = 'default'.freeze,
25
+ AUTH_SERVER = 'auth server'.freeze
26
+ ].freeze
27
+
28
+ # Converts a string or symbol into a valid Server constant.
29
+ def self.from_value(value, default_value = DEFAULT)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip.downcase
33
+ case str
34
+ when 'default' then DEFAULT
35
+ when 'auth_server' then AUTH_SERVER
36
+
37
+ else
38
+ warn "[Server] Unknown server '#{value}', falling back to #{default_value} "
39
+ default_value
40
+ end
41
+ end
42
+ end
43
+
44
+ # All configuration including auth info and base URI for the API access
45
+ # are configured in this class.
46
+ class Configuration < CoreLibrary::HttpClientConfiguration
47
+ # The attribute readers for properties.
48
+ attr_reader :environment, :petstore_auth_credentials, :api_key_credentials
49
+
50
+ class << self
51
+ attr_reader :environments
52
+ end
53
+
54
+ def initialize(
55
+ connection: nil, adapter: :net_http_persistent, timeout: 60,
56
+ max_retries: 0, retry_interval: 1, backoff_factor: 2,
57
+ retry_statuses: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524],
58
+ retry_methods: %i[get put], http_callback: nil, proxy_settings: nil,
59
+ environment: Environment::PRODUCTION, petstore_auth_credentials: nil,
60
+ api_key_credentials: nil
61
+ )
62
+ super connection: connection, adapter: adapter, timeout: timeout,
63
+ max_retries: max_retries, retry_interval: retry_interval,
64
+ backoff_factor: backoff_factor, retry_statuses: retry_statuses,
65
+ retry_methods: retry_methods, http_callback: http_callback,
66
+ proxy_settings: proxy_settings
67
+
68
+ # Current API environment
69
+ @environment = String(environment)
70
+
71
+ # The object holding OAuth 2 Implicit Grant credentials
72
+ @petstore_auth_credentials = petstore_auth_credentials
73
+
74
+ # The object holding Custom Header Signature credentials
75
+ @api_key_credentials = api_key_credentials
76
+
77
+ # The Http Client to use for making requests.
78
+ set_http_client CoreLibrary::FaradayClient.new(self)
79
+ end
80
+
81
+ def clone_with(connection: nil, adapter: nil, timeout: nil,
82
+ max_retries: nil, retry_interval: nil, backoff_factor: nil,
83
+ retry_statuses: nil, retry_methods: nil, http_callback: nil,
84
+ proxy_settings: nil, environment: nil,
85
+ petstore_auth_credentials: nil, api_key_credentials: nil)
86
+ connection ||= self.connection
87
+ adapter ||= self.adapter
88
+ timeout ||= self.timeout
89
+ max_retries ||= self.max_retries
90
+ retry_interval ||= self.retry_interval
91
+ backoff_factor ||= self.backoff_factor
92
+ retry_statuses ||= self.retry_statuses
93
+ retry_methods ||= self.retry_methods
94
+ http_callback ||= self.http_callback
95
+ proxy_settings ||= self.proxy_settings
96
+ environment ||= self.environment
97
+ petstore_auth_credentials ||= self.petstore_auth_credentials
98
+ api_key_credentials ||= self.api_key_credentials
99
+
100
+ Configuration.new(connection: connection, adapter: adapter,
101
+ timeout: timeout, max_retries: max_retries,
102
+ retry_interval: retry_interval,
103
+ backoff_factor: backoff_factor,
104
+ retry_statuses: retry_statuses,
105
+ retry_methods: retry_methods,
106
+ http_callback: http_callback,
107
+ proxy_settings: proxy_settings,
108
+ environment: environment,
109
+ petstore_auth_credentials: petstore_auth_credentials,
110
+ api_key_credentials: api_key_credentials)
111
+ end
112
+
113
+
114
+ # All the environments the SDK can run in.
115
+ ENVIRONMENTS = {
116
+ Environment::PRODUCTION => {
117
+ Server::DEFAULT => '/api/v3',
118
+ Server::AUTH_SERVER => 'https://petstore3.swagger.io/oauth'
119
+ }
120
+ }.freeze
121
+
122
+ # Generates the appropriate base URI for the environment and the server.
123
+ # @param [Configuration::Server] server The server enum for which the base URI is
124
+ # required.
125
+ # @return [String] The base URI.
126
+ def get_base_uri(server = Server::DEFAULT)
127
+ ENVIRONMENTS[environment][server].clone
128
+ end
129
+
130
+ # Builds a Configuration instance using environment variables.
131
+ def self.build_default_config_from_env
132
+ # === Core environment ===
133
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
134
+ timeout = (ENV['TIMEOUT'] || 60).to_f
135
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
136
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
137
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
138
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
139
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
140
+ .split(',')
141
+ .map(&:strip)
142
+ .map do |item|
143
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
144
+ end
145
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
146
+ .split(',')
147
+ .map(&:strip)
148
+ .map do |item|
149
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
150
+ end
151
+
152
+ # === Authentication credentials ===
153
+ petstore_auth_credentials = PetstoreAuthCredentials.from_env
154
+ api_key_credentials = ApiKeyCredentials.from_env
155
+
156
+ # === Proxy settings ===
157
+ proxy_settings = ProxySettings.from_env
158
+
159
+ Configuration.new(
160
+ environment: environment,
161
+ timeout: timeout,
162
+ max_retries: max_retries,
163
+ retry_interval: retry_interval,
164
+ backoff_factor: backoff_factor,
165
+ retry_statuses: retry_statuses,
166
+ retry_methods: retry_methods,
167
+ petstore_auth_credentials: petstore_auth_credentials,
168
+ api_key_credentials: api_key_credentials,
169
+ proxy_settings: proxy_settings
170
+ )
171
+ end
172
+ end
173
+ end
@@ -0,0 +1,60 @@
1
+ # swagger_petstore_open_api30
2
+ #
3
+ # This file was automatically generated by
4
+ # APIMATIC v3.0 ( https://www.apimatic.io ).
5
+
6
+ module SwaggerPetstoreOpenApi30
7
+ # BaseController.
8
+ class BaseController
9
+ include CoreLibrary
10
+ attr_accessor :config, :http_call_back
11
+
12
+ def self.user_agent
13
+ 'APIMATIC 3.0'
14
+ end
15
+
16
+
17
+ GLOBAL_ERRORS = {
18
+ 'default' => ErrorCase.new
19
+ .error_message('HTTP response not OK.')
20
+ .exception_type(APIException)
21
+ }.freeze
22
+
23
+ # Initialization constructor.
24
+ # @param [GlobalConfiguration] global_configuration The instance of GlobalConfiguration.
25
+ def initialize(global_configuration)
26
+ @global_configuration = global_configuration
27
+ @config = @global_configuration.client_configuration
28
+ @http_call_back = @config.http_callback
29
+ @api_call = ApiCall.new(@global_configuration)
30
+ end
31
+
32
+ # Creates a new instance of the request builder.
33
+ # @param [String] http_method The HTTP method to use in the request.
34
+ # @param [String] path The endpoint path to use in the request.
35
+ # @param [String] server The server to extract the base uri for the request.
36
+ # @return [RequestBuilder] The instance of RequestBuilder.
37
+ def new_request_builder(http_method, path, server)
38
+ RequestBuilder.new
39
+ .http_method(http_method)
40
+ .path(path)
41
+ .server(server)
42
+ end
43
+
44
+ # Creates a new instance of the response handler.
45
+ # @return [ResponseHandler] The instance of ResponseHandler.
46
+ def new_response_handler
47
+ ResponseHandler.new
48
+ end
49
+
50
+ # Creates a new instance of the parameter.
51
+ # @param [String|optional] key The key of the parameter.
52
+ # @param [Object] value The value of the parameter.
53
+ # @return [Parameter] The instance of Parameter.
54
+ def new_parameter(value, key: nil)
55
+ Parameter.new
56
+ .key(key)
57
+ .value(value)
58
+ end
59
+ end
60
+ end