stackone_hris_client 1.2.2 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b241dfbdc84f9582c191a12537b373ba49a14bdb881696ba1c7a64e1f74fb44c
4
- data.tar.gz: 4ad67d1f9c45f73bfe9bf01719756dfcf2a4a4c6e6415989598e07039b3c52db
3
+ metadata.gz: 1f1bac9ffe1525736d5a4ee2b28ee7e86cc2dd02bad121ecca41aa0ab4e63626
4
+ data.tar.gz: feabaa81170c42b918e0b38779adc0c3f7880fdd6986af237b3a7b71c553c0d6
5
5
  SHA512:
6
- metadata.gz: d06a74f8d0f275a95872fc8aad9202f98ad2a0bf26419f6bf1ece43e3df44b9f14e1ed5de9861170d363b25003fae1701e16e7d0427f2a47f1fb35eeecdb7a67
7
- data.tar.gz: ca8692bc6cd8bd58e0e0891d6c126f19e538b5d596bacca4d14e2a20f2a438ecf8be52b6dbbb4d737f075b93aa5873fdadfc66a903424b305f3ade27e889f5d8
6
+ metadata.gz: ddc9ed201b396bdd1bece98c4a182ce9fa922c613a5559b6e708d15ad271238ae40c8713b29ce8913ce712fb3b9caf5942423ad264b3587dc44fd02a28204117
7
+ data.tar.gz: 1e21f2116a2d4808dd455e3b9ea6759c3c12b79a86a6dfede62b10cda78b2927e15c58ba9c893d80dc4f275812ea994522fe64f0455e702770af37ce508a4a23
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stackone_hris_client (1.2.2)
4
+ stackone_hris_client (1.3.1)
5
5
  typhoeus (~> 1.0, >= 1.0.1)
6
6
 
7
7
  GEM
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.2.2
10
+ - Package version: 1.3.1
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.2.2.gem
26
+ gem install ./stackone_hris_client-1.3.1.gem
27
27
  ```
28
28
 
29
- (for development, run `gem install --dev ./stackone_hris_client-1.2.2.gem` to install the development dependencies)
29
+ (for development, run `gem install --dev ./stackone_hris_client-1.3.1.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.2.2'
35
+ gem 'stackone_hris_client', '~> 1.3.1'
36
36
 
37
37
  ### Install from Git
38
38
 
data/gem-config.yml CHANGED
@@ -10,5 +10,5 @@ additionalProperties:
10
10
  gemName: "stackone_hris_client"
11
11
  gemRequiredRubyVersion: ">= 2.7"
12
12
  gemSummary: "StackOne HRIS client gem"
13
- gemVersion: "1.2.2"
13
+ gemVersion: "1.3.1"
14
14
  library: "typhoeus"
@@ -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 call_api(http_method, path, opts = {})
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 = 20
190
+ @initial_backoff_seconds = 30
191
+ @max_backoff_seconds = 180
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?
@@ -11,5 +11,5 @@ OpenAPI Generator version: 6.5.0
11
11
  =end
12
12
 
13
13
  module StackOneHRIS
14
- VERSION = '1.2.2'
14
+ VERSION = '1.3.1'
15
15
  end
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.2.2
4
+ version: 1.3.1
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-05 00:00:00.000000000 Z
11
+ date: 2023-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus