stackone_hris_client 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +4 -4
- data/gem-config.yml +1 -1
- data/lib/stackone_hris_client/api_client.rb +42 -1
- data/lib/stackone_hris_client/configuration.rb +18 -0
- data/lib/stackone_hris_client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dd0114d0ac370241598829a838c46bfddb6ccec8b4a03f3a3daa03241df32410
|
4
|
+
data.tar.gz: cf4c1f56e1b9ed94b542fc649ce6dd60f37b5a21d1234d3fcde08bc96e4729ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd9b24135b34572c928be4254ab41a8f2e49b371928049b628d3e1d833e1805964da9d767a480d07c6029c49c10f3ce097cc194762a007f5db913d5002ea451a
|
7
|
+
data.tar.gz: 27f5caeec05e7216f9ca0b31c3c9b09e76d88878c3660cd3c33703cdf2acf663558c7a6ba9829e0ac910b639cb751462c1c88318317a51d088b316d9d9556a90
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -7,7 +7,7 @@ The documentation for the StackOne Unified API - HRIS
|
|
7
7
|
This SDK is automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
|
8
8
|
|
9
9
|
- API version: 1.0.0
|
10
|
-
- Package version: 1.
|
10
|
+
- Package version: 1.3.0
|
11
11
|
- Build package: org.openapitools.codegen.languages.RubyClientCodegen
|
12
12
|
|
13
13
|
## Installation
|
@@ -23,16 +23,16 @@ gem build stackone_hris_client.gemspec
|
|
23
23
|
Then either install the gem locally:
|
24
24
|
|
25
25
|
```shell
|
26
|
-
gem install ./stackone_hris_client-1.
|
26
|
+
gem install ./stackone_hris_client-1.3.0.gem
|
27
27
|
```
|
28
28
|
|
29
|
-
(for development, run `gem install --dev ./stackone_hris_client-1.
|
29
|
+
(for development, run `gem install --dev ./stackone_hris_client-1.3.0.gem` to install the development dependencies)
|
30
30
|
|
31
31
|
or publish the gem to a gem hosting service, e.g. [RubyGems](https://rubygems.org/).
|
32
32
|
|
33
33
|
Finally add this to the Gemfile:
|
34
34
|
|
35
|
-
gem 'stackone_hris_client', '~> 1.
|
35
|
+
gem 'stackone_hris_client', '~> 1.3.0'
|
36
36
|
|
37
37
|
### Install from Git
|
38
38
|
|
data/gem-config.yml
CHANGED
@@ -46,7 +46,7 @@ module StackOneHRIS
|
|
46
46
|
#
|
47
47
|
# @return [Array<(Object, Integer, Hash)>] an array of 3 elements:
|
48
48
|
# the data deserialized from response body (could be nil), response status code and response headers.
|
49
|
-
def
|
49
|
+
def call_api_basic(http_method, path, opts = {})
|
50
50
|
request = build_request(http_method, path, opts)
|
51
51
|
response = request.run
|
52
52
|
|
@@ -77,6 +77,12 @@ module StackOneHRIS
|
|
77
77
|
return data, response.code, response.headers
|
78
78
|
end
|
79
79
|
|
80
|
+
def call_api(http_method, path, opts = {})
|
81
|
+
retries_errors_with_exponential_backoff do
|
82
|
+
return call_api_basic(http_method, path, opts)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
80
86
|
# Builds the HTTP request
|
81
87
|
#
|
82
88
|
# @param [String] http_method HTTP method/verb (e.g. POST)
|
@@ -158,6 +164,41 @@ module StackOneHRIS
|
|
158
164
|
data
|
159
165
|
end
|
160
166
|
|
167
|
+
def retries_errors_with_exponential_backoff(
|
168
|
+
max_retries: @config.max_retries,
|
169
|
+
initial_backoff_seconds: @config.initial_backoff_seconds,
|
170
|
+
max_backoff_seconds: @config.max_backoff_seconds,
|
171
|
+
&block
|
172
|
+
)
|
173
|
+
retry_count = 0
|
174
|
+
backoff_seconds = initial_backoff_seconds
|
175
|
+
|
176
|
+
loop do
|
177
|
+
begin
|
178
|
+
yield
|
179
|
+
break
|
180
|
+
rescue ApiError => e
|
181
|
+
raise e unless @config.retry_status_codes.include? e.code
|
182
|
+
|
183
|
+
if @config.debugging
|
184
|
+
@config.logger.debug "The error code (#{e.code}) matches retry_status_codes list. Retrying #(#{retry_count}) in #{backoff_seconds}s..."
|
185
|
+
end
|
186
|
+
|
187
|
+
if retry_count >= max_retries
|
188
|
+
if @config.debugging
|
189
|
+
@config.logger.debug "Maximum number of retries (#{max_retries}) reached. Raising exception: #{e}"
|
190
|
+
end
|
191
|
+
|
192
|
+
raise e
|
193
|
+
else
|
194
|
+
sleep backoff_seconds
|
195
|
+
retry_count += 1
|
196
|
+
backoff_seconds = [backoff_seconds * 2, max_backoff_seconds].min
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
161
202
|
# Save response body into a file in (the defined) temporary folder, using the filename
|
162
203
|
# from the "Content-Disposition" header if provided, otherwise a random filename.
|
163
204
|
# The response body is written to the file in chunks in order to handle files which
|
@@ -152,6 +152,18 @@ module StackOneHRIS
|
|
152
152
|
|
153
153
|
attr_accessor :force_ending_format
|
154
154
|
|
155
|
+
# Set this to customize the number of times to retry an API call when a server error occurs.
|
156
|
+
attr_accessor :max_retries
|
157
|
+
|
158
|
+
# Set this to customize the initial number of seconds to wait before retrying an API call when a server error occurs.
|
159
|
+
attr_accessor :initial_backoff_seconds
|
160
|
+
|
161
|
+
# Set this to customize the maximum number of seconds to keep retrying an API call when a server error occurs.
|
162
|
+
attr_accessor :max_backoff_seconds
|
163
|
+
|
164
|
+
# Define the status codes that should be retried.
|
165
|
+
attr_accessor :retry_status_codes
|
166
|
+
|
155
167
|
def initialize
|
156
168
|
@scheme = 'https'
|
157
169
|
@host = 'stackone.com'
|
@@ -173,6 +185,12 @@ module StackOneHRIS
|
|
173
185
|
@debugging = false
|
174
186
|
@inject_format = false
|
175
187
|
@force_ending_format = false
|
188
|
+
|
189
|
+
@max_retries = 5
|
190
|
+
@initial_backoff_seconds = 1
|
191
|
+
@max_backoff_seconds = 60
|
192
|
+
@retry_status_codes = [429]
|
193
|
+
|
176
194
|
@logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT)
|
177
195
|
|
178
196
|
yield(self) if block_given?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stackone_hris_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- StackOne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-04-
|
11
|
+
date: 2023-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|