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.
- checksums.yaml +4 -4
- data/lib/nypl_sierra_api_client.rb +19 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7216ca46bebde733ae89eca1d88081d1d5cf2db7543dcdf801e433a4400ee4c4
|
4
|
+
data.tar.gz: bc2076e537315b8324bd4f54748090d68aa1d23c761aa9b44d948e95347864e8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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}"
|