nypl_sierra_api_client 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nypl_sierra_api_client.rb +19 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: caabcc105e5fa564b09906a50a7c2c83781435ae2997aeb5b1b546c2a5d5196d
4
- data.tar.gz: ee28dd954ac82a925c01d4b3c386d7116c45a3a4a9901c19c725f3570c6dd51e
3
+ metadata.gz: 7216ca46bebde733ae89eca1d88081d1d5cf2db7543dcdf801e433a4400ee4c4
4
+ data.tar.gz: bc2076e537315b8324bd4f54748090d68aa1d23c761aa9b44d948e95347864e8
5
5
  SHA512:
6
- metadata.gz: 02744457c93e208183dfd10a918ab47bd2be2945b1ab3877ac4af15648da4636e71edde276d73dcc2f9f5e971d72c6cf027c9ac2bad99f58f1ae6d7de9c7946d
7
- data.tar.gz: bc02013959688226a4e115deb6ed7dce14c2e4e15b136905d79a5371d9e84450982662cbbbcdf9ee14d8258385cc680be0f2c2b2e83100e93f0e08af1d3a0c52
6
+ metadata.gz: ee64dd2daae74d47757acba0df00a61c0e8b00d6f52a35a3c2c1fc53f43a8542436dac51463cd723c66333f122c70b07abe6db1e2ef7d78899f084206f14d29b
7
+ data.tar.gz: 7c09588f8be4a03f56519523008b116443930ef0b39880d14860305aa64278cbfec5a0ba1b9216ab1dced91b757013ed820abea4f0c96496488ec216ae023c86
@@ -127,12 +127,31 @@ class SierraApiClient
127
127
  raise SierraApiClientTokenError.new(message)
128
128
  end
129
129
 
130
+ if response.body == '' && response.code.to_i < 300 && response.code.to_i >= 200
131
+ reattempt_request request, options
132
+ end
133
+
130
134
  reset_retries if @retries > 0
131
135
  SierraApiResponse.new(response)
132
136
  end
133
137
 
138
+
139
+ def reattempt_request request, options
140
+ if @retries < 3
141
+ logger.warn "#{request.method} request retry ##{@retries} due to empty response from Sierra API"
142
+ sleep 2 ** (@retries - 1)
143
+ @retries += 1
144
+ execute request, options
145
+ else
146
+ reset_retries
147
+ raise SierraApiResponseError.new "Sierra API Client: Request failed after 3 empty responses received from Sierra API"
148
+ end
149
+ end
150
+
151
+
134
152
  def reauthenticate_and_reattempt request, options
135
153
  @retries += 1
154
+ sleep 2 ** (@retries - 1)
136
155
  authenticate!
137
156
  # Reset bearer token header
138
157
  request['Authorization'] = "Bearer #{@access_token}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nypl_sierra_api_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nonword