wesley-key-sdk 1.1.2 → 2.0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9256ecaae367cc849e40e6270dfcb9fcc7f2a31d32e394f95718d47328cd176c
4
- data.tar.gz: 19a7a97b270b1a9d27d8fbe005cfdea1c09df6cf681bc2014670388dd67c83a3
3
+ metadata.gz: bcd3d338d691a30b884a0b016c1ccd0b9d056bf8c7aef2bf633f6f7fd7e44110
4
+ data.tar.gz: 2ad11507830d6c4b90f54bca2c1f37ea4b38cd669711d8a322ad6dac2e1770d5
5
5
  SHA512:
6
- metadata.gz: 51ec09d8d57e235c433945db44408cc7c388f5456aa313c32b315d4f0012b03cc2a367988001dc684e2f72c7d1a9dfa834de47720326839e371feee461fc3cdc
7
- data.tar.gz: 3f26e151f0e6fa13640ada893f562649c07652b32c3e1202fbec2156c5df5ee3779b635da0801aad6d12a76e60db5940ee1295e9a1a584b1f862902b5a712292
6
+ metadata.gz: 8d8262d7ec1091cd1517cc1e2ecd6b647e83a11b4440ea497c46b6aabeea4ab49d1bb8efaa4f60097527e508946eb91ae15b445b992e38bcd2f2eb8b43493b8b
7
+ data.tar.gz: 45c53a21fe782533fc4fc94e5c87efb97a15283a0fef8b61d58ddd20b7ba65e38d3656490250ea3c4edf3f9849e23e107b30e1a649099930025cab0a69009231
data/README.md CHANGED
@@ -10,16 +10,51 @@ This is a sample API to demonstrate an OpenAPI spec with multiple endpoints and
10
10
  Install the gem from the command line:
11
11
 
12
12
  ```bash
13
- gem install wesley-key-sdk -v 1.1.2
13
+ gem install wesley-key-sdk -v 2.0.0
14
14
  ```
15
15
 
16
16
  Or add the gem to your Gemfile and run `bundle`:
17
17
 
18
18
  ```ruby
19
- gem 'wesley-key-sdk', '1.1.2'
19
+ gem 'wesley-key-sdk', '2.0.0'
20
20
  ```
21
21
 
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.2).
22
+ For additional gem details, see the [RubyGems page for the wesley-key-sdk gem](https://rubygems.org/gems/wesley-key-sdk/versions/2.0.0).
23
+
24
+ ## IRB Console Usage
25
+
26
+ You can explore the SDK interactively using IRB in two ways
27
+
28
+ ### 1. Use IRB with Installed Gem
29
+
30
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and type the following command to start the irb console.
31
+
32
+ ```bash
33
+ irb
34
+ ```
35
+
36
+ Now you can load the SDK in the IRB
37
+
38
+ ```ruby
39
+ require 'cypress_test_api'
40
+ include CypressTestApi
41
+ ```
42
+
43
+ ### 2. Use IRB within SDK
44
+
45
+ Open your system terminal (Command Prompt, Git Bash or macOS Terminal) and navigate to the root folder of SDK.
46
+
47
+ ```
48
+ cd path/to/cypress_test_api
49
+ ```
50
+
51
+ Now you can start the preconfigured irb console by running the following command
52
+
53
+ ```bash
54
+ ruby bin/console
55
+ ```
56
+
57
+ **_Note:_** This automatically loads the SDK from lib/
23
58
 
24
59
  ## Test the SDK
25
60
 
@@ -31,7 +66,7 @@ rake
31
66
 
32
67
  ## Initialize the API Client
33
68
 
34
- **_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/client.md)
69
+ **_Note:_** Documentation for the client can be found [here.](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/client.md)
35
70
 
36
71
  The following parameters are configurable for the API Client:
37
72
 
@@ -48,10 +83,12 @@ The following parameters are configurable for the API Client:
48
83
  | retry_statuses | `Array` | A list of HTTP statuses to retry. <br> **Default: [408, 413, 429, 500, 502, 503, 504, 521, 522, 524]** |
49
84
  | retry_methods | `Array` | A list of HTTP methods to retry. <br> **Default: %i[get put]** |
50
85
  | 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.2/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
86
+ | proxy_settings | [`ProxySettings`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/proxy-settings.md) | Optional proxy configuration to route HTTP requests through a proxy server. |
52
87
 
53
88
  The API client can be initialized as follows:
54
89
 
90
+ ### Code-Based Client Initialization
91
+
55
92
  ```ruby
56
93
  require 'cypress_test_api'
57
94
  include CypressTestApi
@@ -62,23 +99,36 @@ client = Client.new(
62
99
  )
63
100
  ```
64
101
 
102
+ ### Environment-Based Client Initialization
103
+
104
+ ```ruby
105
+ require 'cypress_test_api'
106
+ include CypressTestApi
107
+
108
+ # Create client from environment
109
+ client = Client.from_env
110
+ ```
111
+
112
+ See the [`Environment-Based Client Initialization`](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/environment-based-client-initialization.md) section for details.
113
+
65
114
  ## List of APIs
66
115
 
67
- * [API](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/controllers/api.md)
116
+ * [API](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/controllers/api.md)
68
117
 
69
118
  ## SDK Infrastructure
70
119
 
71
120
  ### Configuration
72
121
 
73
- * [ProxySettings](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/proxy-settings.md)
122
+ * [ProxySettings](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/proxy-settings.md)
123
+ * [Environment-Based Client Initialization](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/environment-based-client-initialization.md)
74
124
 
75
125
  ### HTTP
76
126
 
77
- * [HttpResponse](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/http-response.md)
78
- * [HttpRequest](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/http-request.md)
127
+ * [HttpResponse](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/http-response.md)
128
+ * [HttpRequest](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/http-request.md)
79
129
 
80
130
  ### Utilities
81
131
 
82
- * [ApiHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/api-helper.md)
83
- * [DateTimeHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/1.1.2/doc/date-time-helper.md)
132
+ * [ApiHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/api-helper.md)
133
+ * [DateTimeHelper](https://www.github.com/ZahraN444/wesley-key-ruby-sdk/tree/2.0.0/doc/date-time-helper.md)
84
134
 
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 'cypress_test_api'
8
+
9
+ puts 'CypressTestApi SDK loaded!'
10
+ puts 'You can now create a client with: client = CypressTestApi::Client.new'
11
+ puts 'Or use from_env: client = CypressTestApi::Client.from_env'
12
+
13
+ # Start an interactive IRB session
14
+ require 'irb'
15
+ IRB.start
@@ -9,6 +9,10 @@ module CypressTestApi
9
9
  include CoreLibrary
10
10
  attr_reader :config
11
11
 
12
+ def user_agent_detail
13
+ config.user_agent_detail
14
+ end
15
+
12
16
  # Access to client controller.
13
17
  # @return [APIController] Returns the controller instance.
14
18
  def client
@@ -43,5 +47,12 @@ module CypressTestApi
43
47
  .global_errors(BaseController::GLOBAL_ERRORS)
44
48
  .user_agent(BaseController.user_agent)
45
49
  end
50
+
51
+ # Creates a client directly from environment variables.
52
+ def self.from_env(**overrides)
53
+ default_config = Configuration.build_default_config_from_env
54
+ new_config = default_config.clone_with(**overrides)
55
+ new(config: new_config)
56
+ end
46
57
  end
47
58
  end
@@ -9,6 +9,13 @@ module CypressTestApi
9
9
  ENVIRONMENT = [
10
10
  PRODUCTION = 'production'.freeze
11
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
12
19
  end
13
20
 
14
21
  # An enum for API servers.
@@ -16,6 +23,13 @@ module CypressTestApi
16
23
  SERVER = [
17
24
  DEFAULT = 'default'.freeze
18
25
  ].freeze
26
+
27
+ # Converts a string or symbol into a valid Server constant.
28
+ def self.from_value(value, default_value = DEFAULT)
29
+ return default_value if value.nil?
30
+
31
+ default_value
32
+ end
19
33
  end
20
34
 
21
35
  # All configuration including auth info and base URI for the API access
@@ -99,5 +113,44 @@ module CypressTestApi
99
113
  ENVIRONMENTS[environment][server], parameters
100
114
  )
101
115
  end
116
+
117
+ # Builds a Configuration instance using environment variables.
118
+ def self.build_default_config_from_env
119
+ # === Core environment ===
120
+ environment = Environment.from_value(ENV.fetch('ENVIRONMENT', 'production'))
121
+ default_host = ENV.fetch('DEFAULT_HOST', 'www.example.com')
122
+ timeout = (ENV['TIMEOUT'] || 60).to_f
123
+ max_retries = (ENV['MAX_RETRIES'] || 0).to_i
124
+ retry_interval = (ENV['RETRY_INTERVAL'] || 1).to_f
125
+ backoff_factor = (ENV['BACKOFF_FACTOR'] || 2).to_f
126
+ retry_statuses = ENV.fetch('RETRY_STATUSES',
127
+ '[408, 413, 429, 500, 502, 503, 504, 521, 522, 524]').gsub(/[\[\]]/, '')
128
+ .split(',')
129
+ .map(&:strip)
130
+ .map do |item|
131
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
132
+ end
133
+ retry_methods = ENV.fetch('RETRY_METHODS', '%i[get put]').gsub(/[\[\]]/, '')
134
+ .split(',')
135
+ .map(&:strip)
136
+ .map do |item|
137
+ item.match?(/\A\d+\z/) ? item.to_i : item.downcase
138
+ end
139
+
140
+ # === Proxy settings ===
141
+ proxy_settings = ProxySettings.from_env
142
+
143
+ Configuration.new(
144
+ environment: environment,
145
+ default_host: default_host,
146
+ timeout: timeout,
147
+ max_retries: max_retries,
148
+ retry_interval: retry_interval,
149
+ backoff_factor: backoff_factor,
150
+ retry_statuses: retry_statuses,
151
+ retry_methods: retry_methods,
152
+ proxy_settings: proxy_settings
153
+ )
154
+ end
102
155
  end
103
156
  end
@@ -9,5 +9,14 @@ module CypressTestApi
9
9
  # including optional basic authentication.
10
10
  #
11
11
  class ProxySettings < CoreLibrary::ProxySettings
12
+ def self.from_env
13
+ address = ENV['PROXY_ADDRESS']
14
+ port = ENV['PROXY_PORT']
15
+ username = ENV['PROXY_USERNAME']
16
+ password = ENV['PROXY_PASSWORD']
17
+ return nil if address.nil? || address.strip.empty?
18
+
19
+ new(address: address, port: port, username: username, password: password)
20
+ end
12
21
  end
13
22
  end
@@ -22,5 +22,19 @@ module CypressTestApi
22
22
 
23
23
  CUSTOM_ENUM.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = VALUE1)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'value1' then VALUE1
33
+ when 'value2' then VALUE2
34
+ when 'value3' then VALUE3
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -25,5 +25,20 @@ module CypressTestApi
25
25
 
26
26
  O_AUTH_SCOPE_O_AUTH_ACG_ENUM.include?(value)
27
27
  end
28
+
29
+ def self.from_value(value, default_value = ENUM_FILE_REQUESTSREAD)
30
+ return default_value if value.nil?
31
+
32
+ str = value.to_s.strip
33
+
34
+ case str.downcase
35
+ when 'enum_file_requestsread' then ENUM_FILE_REQUESTSREAD
36
+ when 'zahra' then ZAHRA
37
+ when 'test1' then TEST1
38
+ when 'selection' then SELECTION
39
+ else
40
+ default_value
41
+ end
42
+ end
28
43
  end
29
44
  end
@@ -22,5 +22,19 @@ module CypressTestApi
22
22
 
23
23
  STATUS11_ENUM.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = ENUMVALUE1)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'enumvalue1' then ENUMVALUE1
33
+ when 'enumvalue2' then ENUMVALUE2
34
+ when 'enumvalue3' then ENUMVALUE3
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -22,5 +22,19 @@ module CypressTestApi
22
22
 
23
23
  STATUS1_ENUM.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = ENUMVALUE1)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'enumvalue1' then ENUMVALUE1
33
+ when 'enumvalue2' then ENUMVALUE2
34
+ when 'enumvalue3' then ENUMVALUE3
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -22,5 +22,19 @@ module CypressTestApi
22
22
 
23
23
  STATUS_ENUM.include?(value)
24
24
  end
25
+
26
+ def self.from_value(value, default_value = ACTIVE)
27
+ return default_value if value.nil?
28
+
29
+ str = value.to_s.strip
30
+
31
+ case str.downcase
32
+ when 'active' then ACTIVE
33
+ when 'inactive' then INACTIVE
34
+ when 'pending' then PENDING
35
+ else
36
+ default_value
37
+ end
38
+ end
25
39
  end
26
40
  end
@@ -16,14 +16,8 @@ class ControllerTestBase < Minitest::Test
16
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
-
24
19
  # Initializes the base test controller
25
20
  def setup_class
26
- _config = create_configuration
27
- @client = Client.new(config: _config)
21
+ @client = Client.from_env(http_callback: HttpResponseCatcher.new)
28
22
  end
29
23
  end
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: 1.1.2
4
+ version: 2.0.0
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-08-29 00:00:00.000000000 Z
11
+ date: 2025-11-28 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.2
19
+ version: 0.2.3
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.2
26
+ version: 0.2.3
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.19
33
+ version: 0.3.20
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.19
40
+ version: 0.3.20
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: apimatic_faraday_client_adapter
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - LICENSE
91
91
  - README.md
92
+ - bin/console
92
93
  - lib/cypress_test_api.rb
93
94
  - lib/cypress_test_api/api_helper.rb
94
95
  - lib/cypress_test_api/client.rb