wesley-key-sdk 1.1.3 → 2.0.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 (64) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +1 -1
  3. data/README.md +110 -18
  4. data/bin/console +15 -0
  5. data/lib/{cypress_test_api → swagger_petstore}/api_helper.rb +2 -2
  6. data/lib/swagger_petstore/client.rb +95 -0
  7. data/lib/swagger_petstore/configuration.rb +197 -0
  8. data/lib/{cypress_test_api → swagger_petstore}/controllers/base_controller.rb +2 -2
  9. data/lib/swagger_petstore/controllers/pet_controller.rb +206 -0
  10. data/lib/swagger_petstore/controllers/store_controller.rb +94 -0
  11. data/lib/swagger_petstore/controllers/user_controller.rb +165 -0
  12. data/lib/{cypress_test_api → swagger_petstore}/exceptions/api_exception.rb +2 -2
  13. data/lib/swagger_petstore/exceptions/o_auth_provider_exception.rb +64 -0
  14. data/lib/swagger_petstore/http/auth/api_key.rb +52 -0
  15. data/lib/swagger_petstore/http/auth/http_basic.rb +62 -0
  16. data/lib/swagger_petstore/http/auth/petstore_auth.rb +113 -0
  17. data/lib/{cypress_test_api → swagger_petstore}/http/http_call_back.rb +2 -2
  18. data/lib/{cypress_test_api → swagger_petstore}/http/http_method_enum.rb +2 -2
  19. data/lib/{cypress_test_api → swagger_petstore}/http/http_request.rb +2 -2
  20. data/lib/{cypress_test_api → swagger_petstore}/http/http_response.rb +2 -2
  21. data/lib/swagger_petstore/http/proxy_settings.rb +22 -0
  22. data/lib/{cypress_test_api/models/message2.rb → swagger_petstore/models/api_response.rb} +24 -14
  23. data/lib/{cypress_test_api → swagger_petstore}/models/base_model.rb +2 -2
  24. data/lib/{cypress_test_api/models/item_response.rb → swagger_petstore/models/category.rb} +10 -19
  25. data/lib/{cypress_test_api/models/deer.rb → swagger_petstore/models/category2.rb} +21 -18
  26. data/lib/swagger_petstore/models/content_type_enum.rb +26 -0
  27. data/lib/swagger_petstore/models/o_auth_provider_error_enum.rb +62 -0
  28. data/lib/swagger_petstore/models/o_auth_scope_petstore_auth_enum.rb +36 -0
  29. data/lib/swagger_petstore/models/o_auth_token.rb +96 -0
  30. data/lib/swagger_petstore/models/order.rb +120 -0
  31. data/lib/swagger_petstore/models/pet.rb +117 -0
  32. data/lib/swagger_petstore/models/pet_request.rb +117 -0
  33. data/lib/swagger_petstore/models/status1_enum.rb +40 -0
  34. data/lib/swagger_petstore/models/status2_enum.rb +40 -0
  35. data/lib/swagger_petstore/models/status_enum.rb +40 -0
  36. data/lib/swagger_petstore/models/store_order_request.rb +120 -0
  37. data/lib/{cypress_test_api/models/response_http404.rb → swagger_petstore/models/tag.rb} +18 -9
  38. data/lib/swagger_petstore/models/user.rb +132 -0
  39. data/lib/swagger_petstore/models/user_request.rb +132 -0
  40. data/lib/{cypress_test_api → swagger_petstore}/utilities/date_time_helper.rb +2 -2
  41. data/lib/{cypress_test_api → swagger_petstore}/utilities/file_wrapper.rb +2 -2
  42. data/lib/swagger_petstore.rb +62 -0
  43. data/test/controllers/controller_test_base.rb +14 -11
  44. data/test/controllers/test_store_controller.rb +31 -0
  45. data/test/http_response_catcher.rb +2 -2
  46. metadata +46 -38
  47. data/lib/cypress_test_api/client.rb +0 -47
  48. data/lib/cypress_test_api/configuration.rb +0 -103
  49. data/lib/cypress_test_api/controllers/api_controller.rb +0 -102
  50. data/lib/cypress_test_api/http/proxy_settings.rb +0 -13
  51. data/lib/cypress_test_api/models/custom_enum.rb +0 -26
  52. data/lib/cypress_test_api/models/item.rb +0 -166
  53. data/lib/cypress_test_api/models/lion.rb +0 -68
  54. data/lib/cypress_test_api/models/message.rb +0 -68
  55. data/lib/cypress_test_api/models/multiple_arrays_request.rb +0 -70
  56. data/lib/cypress_test_api/models/nac_tag.rb +0 -265
  57. data/lib/cypress_test_api/models/o_auth_scope_o_auth_acg_enum.rb +0 -29
  58. data/lib/cypress_test_api/models/response_http400.rb +0 -62
  59. data/lib/cypress_test_api/models/status11_enum.rb +0 -26
  60. data/lib/cypress_test_api/models/status1_enum.rb +0 -26
  61. data/lib/cypress_test_api/models/status_enum.rb +0 -26
  62. data/lib/cypress_test_api/models/tokens_request.rb +0 -60
  63. data/lib/cypress_test_api.rb +0 -55
  64. data/test/controllers/test_api_controller.rb +0 -40
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c3ea6f79455b8271f043bcdc0bba2a2d18c54981bb9f3ec2768fa599e2c1d138
4
- data.tar.gz: 580d402b865b741c7e00af607f78b872fed04dc3c9b13ce946eac315af186f4f
3
+ metadata.gz: f7b95e92f79c8960c60c731fbdfab810714ecab62a0c8ff5cfa4a9a7bca45554
4
+ data.tar.gz: e435438de0eac36322e87d15c35d20d3bdd576d50b21a4eb28f8c9b15d684d9b
5
5
  SHA512:
6
- metadata.gz: d4e91d1d6be472481870d8bc05c1ee3a8f707e164a74932ac10e21a1f741ea95d02a5aaecd59c4dab177e1b9492f1679eed1cae1bb920636816248b024fb9f4b
7
- data.tar.gz: 0eac539342d687353f4a4a54b095d3230ee01fa5c7696728c7e171611b80d47298d4b230cdebe0150de5bc4e2816a8c30dd8873d610034b1a1fe117258a369a0
6
+ metadata.gz: ece54c83895b95f4f0552d9629e5b7df46d10134c9fa66efb5ba461d6c37b583a864e7f1bdfd25bb5a1db096bb17b7f687674446a3584a2832148e94e17ec5cd
7
+ data.tar.gz: 552ca4bd24b688068d8c8e48be59e4fed1575a443d4cfa6eb0da34dfac6d85a0c046b4fe7940e785587a22aa0174772ef3e33e6927fa56c9562d80c34f5202d6
data/LICENSE CHANGED
@@ -3,7 +3,7 @@ License:
3
3
  The MIT License (MIT)
4
4
  http://opensource.org/licenses/MIT
5
5
 
6
- Copyright (c) 2014 - 2025 APIMATIC Limited
6
+ Copyright (c) 2014 - 2026 APIMATIC Limited
7
7
 
8
8
  Permission is hereby granted, free of charge, to any person obtaining a copy
9
9
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,25 +1,62 @@
1
1
 
2
- # Getting Started with Cypress Test API
2
+ # Getting Started with Swagger Petstore
3
3
 
4
4
  ## Introduction
5
5
 
6
- This is a sample API to demonstrate an OpenAPI spec with multiple endpoints and a custom model.
6
+ This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters.
7
+
8
+ Find out more about Swagger: [http://swagger.io](http://swagger.io)
7
9
 
8
10
  ## Install the Package
9
11
 
10
12
  Install the gem from the command line:
11
13
 
12
14
  ```bash
13
- gem install wesley-key-sdk -v 1.1.3
15
+ gem install wesley-key-sdk -v 2.0.1
14
16
  ```
15
17
 
16
18
  Or add the gem to your Gemfile and run `bundle`:
17
19
 
18
20
  ```ruby
19
- gem 'wesley-key-sdk', '1.1.3'
21
+ gem 'wesley-key-sdk', '2.0.1'
22
+ ```
23
+
24
+ For additional gem details, see the [RubyGems page for the wesley-key-sdk gem](https://rubygems.org/gems/wesley-key-sdk/versions/2.0.1).
25
+
26
+ ## IRB Console Usage
27
+
28
+ You can explore the SDK interactively using IRB in two ways
29
+
30
+ ### 1. Use IRB with Installed Gem
31
+
32
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
33
+
34
+ ```bash
35
+ irb
36
+ ```
37
+
38
+ Now you can load the SDK in the IRB
39
+
40
+ ```ruby
41
+ require 'swagger_petstore'
42
+ include SwaggerPetstore
43
+ ```
44
+
45
+ ### 2. Use IRB within SDK
46
+
47
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
48
+
49
+ ```
50
+ cd path/to/swagger_petstore
20
51
  ```
21
52
 
22
- For additional gem details, see the [RubyGems page for the wesley-key-sdk gem](https://rubygems.org/gems/wesley-key-sdk/versions/1.1.3).
53
+ Now you can start the preconfigured irb console by running the following command
54
+
55
+ ```bash
56
+ ruby bin/console
57
+ ```
58
+
59
+ **_Note:_** This automatically loads the SDK from lib/
23
60
 
24
61
  ## Test the SDK
25
62
 
@@ -31,13 +68,13 @@ rake
31
68
 
32
69
  ## Initialize the API Client
33
70
 
34
- **_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/client.md)
71
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/client.md)
35
72
 
36
73
  The following parameters are configurable for the API Client:
37
74
 
38
75
  | Parameter | Type | Description |
39
76
  | --- | --- | --- |
40
- | default_host | `String` | *Default*: `'www.example.com'` |
77
+ | test_header | `String` | This is a test header<br>*Default*: `'TestHeaderDefaultValue'` |
41
78
  | environment | `Environment` | The API environment. <br> **Default: `Environment.PRODUCTION`** |
42
79
  | connection | `Faraday::Connection` | The Faraday connection object passed by the SDK user for making requests |
43
80
  | adapter | `Faraday::Adapter` | The Faraday adapter object passed by the SDK user for performing http requests |
@@ -48,37 +85,92 @@ The following parameters are configurable for the API Client:
48
85
  | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
49
86
  | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
50
87
  | http_callback | `HttpCallBack` | The Http CallBack allows defining callables for pre and post API calls. |
51
- | proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
88
+ | proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
89
+ | api_key_credentials | [`ApiKeyCredentials`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/custom-header-signature.md) | The credential object for Custom Header Signature |
90
+ | http_basic_credentials | [`HttpBasicCredentials`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/basic-authentication.md) | The credential object for Basic Authentication |
91
+ | petstore_auth_credentials | [`PetstoreAuthCredentials`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/oauth-2-implicit-grant.md) | The credential object for OAuth 2 Implicit Grant |
52
92
 
53
93
  The API client can be initialized as follows:
54
94
 
95
+ ### Code-Based Client Initialization
96
+
55
97
  ```ruby
56
- require 'cypress_test_api'
57
- include CypressTestApi
98
+ require 'swagger_petstore'
99
+ include SwaggerPetstore
58
100
 
59
101
  client = Client.new(
60
- environment: Environment::PRODUCTION,
61
- default_host: 'www.example.com'
102
+ test_header: 'TestHeaderDefaultValue',
103
+ api_key_credentials: ApiKeyCredentials.new(
104
+ api_key: 'api_key'
105
+ ),
106
+ http_basic_credentials: HttpBasicCredentials.new(
107
+ username: 'username',
108
+ passwprd: 'passwprd'
109
+ ),
110
+ petstore_auth_credentials: PetstoreAuthCredentials.new(
111
+ o_auth_client_id: 'OAuthClientId',
112
+ o_auth_redirect_uri: 'OAuthRedirectUri',
113
+ o_auth_scopes: [
114
+ OAuthScopePetstoreAuthEnum::READPETS,
115
+ OAuthScopePetstoreAuthEnum::WRITEPETS
116
+ ]
117
+ ),
118
+ environment: Environment::PRODUCTION
62
119
  )
63
120
  ```
64
121
 
122
+ ### Environment-Based Client Initialization
123
+
124
+ ```ruby
125
+ require 'swagger_petstore'
126
+ include SwaggerPetstore
127
+
128
+ # Create client from environment
129
+ client = Client.from_env
130
+ ```
131
+
132
+ See the [`Environment-Based Client Initialization`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/environment-based-client-initialization.md) section for details.
133
+
134
+ ## Environments
135
+
136
+ The SDK can be configured to use a different environment for making API calls. Available environments are:
137
+
138
+ ### Fields
139
+
140
+ | Name | Description |
141
+ | --- | --- |
142
+ | production | **Default** |
143
+ | environment2 | - |
144
+ | environment3 | - |
145
+
146
+ ## Authorization
147
+
148
+ This API uses the following authentication schemes.
149
+
150
+ * [`api_key (Custom Header Signature)`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/custom-header-signature.md)
151
+ * [`httpBasic (Basic Authentication)`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/basic-authentication.md)
152
+ * [`petstore_auth (OAuth 2 Implicit Grant)`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/auth/oauth-2-implicit-grant.md)
153
+
65
154
  ## List of APIs
66
155
 
67
- * [API](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/controllers/api.md)
156
+ * [Pet](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/controllers/pet.md)
157
+ * [Store](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/controllers/store.md)
158
+ * [User](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/controllers/user.md)
68
159
 
69
160
  ## SDK Infrastructure
70
161
 
71
162
  ### Configuration
72
163
 
73
- * [ProxySettings](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/proxy-settings.md)
164
+ * [ProxySettings](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/proxy-settings.md)
165
+ * [Environment-Based Client Initialization](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/environment-based-client-initialization.md)
74
166
 
75
167
  ### HTTP
76
168
 
77
- * [HttpResponse](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/http-response.md)
78
- * [HttpRequest](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/http-request.md)
169
+ * [HttpResponse](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/http-response.md)
170
+ * [HttpRequest](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/http-request.md)
79
171
 
80
172
  ### Utilities
81
173
 
82
- * [ApiHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/api-helper.md)
83
- * [DateTimeHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.3/doc/date-time-helper.md)
174
+ * [ApiHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/api-helper.md)
175
+ * [DateTimeHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.1/doc/date-time-helper.md)
84
176
 
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'
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,9 +1,9 @@
1
- # cypress_test_api
1
+ # swagger_petstore
2
2
  #
3
3
  # This file was automatically generated by APIMATIC v3.0
4
4
  # ( https://www.apimatic.io ).
5
5
 
6
- module CypressTestApi
6
+ module SwaggerPetstore
7
7
  # API utility class
8
8
  class APIHelper < CoreLibrary::ApiHelper
9
9
  end
@@ -0,0 +1,95 @@
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
@@ -0,0 +1,197 @@
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
@@ -1,9 +1,9 @@
1
- # cypress_test_api
1
+ # swagger_petstore
2
2
  #
3
3
  # This file was automatically generated by APIMATIC v3.0
4
4
  # ( https://www.apimatic.io ).
5
5
 
6
- module CypressTestApi
6
+ module SwaggerPetstore
7
7
  # BaseController.
8
8
  class BaseController
9
9
  include CoreLibrary