rail-locator-api 0.0.21 → 0.0.24

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: 4f775a7f5dbab37a454da5e73f4bd5f04dadaa4d47ae5bfa96c83f7ff0380977
4
- data.tar.gz: 6c4e23003da7f24a2e816b25ab3148b79e77a77275b8c6a7b5236a71b68c88e8
3
+ metadata.gz: 642255918703225bbbbe22588fad2836ea34410ca69599b481b05027a45a90fb
4
+ data.tar.gz: db7b2515ae3f3dfb5657d9d47cf49d3a4c61cd7251d3379fcd7f4ce79bb7bfb5
5
5
  SHA512:
6
- metadata.gz: 2aca0f67ea21e47cdf4d6700de4b0c79997126d003e50e29cb238853c18daa782c4944bc667dd6f74e11c429d3ddeab9a4957a7f5920367f25f4b0416e4426b9
7
- data.tar.gz: 9af82abbdf8c1408a936facf4c798fa0af42af1347cb191d72538b9b92b88cd4241c13a7c72016cbaf2aaa3573d3b5f50c6d557c019527d85b66c9f8c651f02d
6
+ metadata.gz: d59a9dc55e51c825311fac4121f28fbee9fe7ad8a7d46cd8808ea1f32cc0e1ecb3ee8fef032bd94ff49054958391d043dd29567dfbbbc54556547a28710e0c32
7
+ data.tar.gz: ade4c0153aecaa5e8c65d8bc8db56bfb4e2638b9df7e26807f4c9da9fee6d21f129e7ff7196828825bb644d98a5afe157e00f6571a36eaacedc8592a8c27e773
@@ -13,13 +13,7 @@ module RailLocatorApi
13
13
  end
14
14
  parse_response(response)
15
15
  rescue => e
16
- if [401, 404].include?(e.try(:response).try(:dig, :status)) && first_time
17
- RailLocatorApi::Request.access_token = RailLocatorApi.generate_access_token.try(:dig, "access_token")
18
- sleep(0.3.second)
19
- self.post(params: params, headers: headers, suffix: suffix, body: body, first_time: false)
20
- else
21
- handle_error(e)
22
- end
16
+ handle_error(e)
23
17
  end
24
18
  end
25
19
 
@@ -32,13 +26,7 @@ module RailLocatorApi
32
26
  end
33
27
  parse_response(response)
34
28
  rescue => e
35
- if [401, 404].include?(e.try(:response).try(:dig, :status)) && first_time
36
- RailLocatorApi::Request.access_token = RailLocatorApi.generate_access_token.try(:dig, "access_token")
37
- sleep(0.3.second)
38
- self.get(params: params, headers: headers, first_time: false)
39
- else
40
- handle_error(e)
41
- end
29
+ handle_error(e)
42
30
  end
43
31
  end
44
32
 
@@ -176,8 +164,8 @@ module RailLocatorApi
176
164
  def validate_api_key
177
165
  case self.api_auth_method
178
166
  when :api_key
179
- unless self.api_key && self.api_endpoint
180
- raise RailLocatorApi::RailLocatorApiError, "You must set an api_key prior to making a call #{self.api_key} #{self.api_endpoint}"
167
+ unless self.access_token && self.api_endpoint
168
+ raise RailLocatorApi::RailLocatorApiError, "You must set an access_token prior to making a call #{self.access_token} #{self.api_endpoint}"
181
169
  end
182
170
  when :base64
183
171
  unless self.api_user_email && self.api_user_password
@@ -1,3 +1,3 @@
1
1
  module RailLocatorApi
2
- VERSION = "0.0.21"
2
+ VERSION = "0.0.24"
3
3
  end
@@ -22,11 +22,10 @@ module RailLocatorApi
22
22
  end
23
23
 
24
24
  response = connection.post RailLocatorApi.keycloak_token_url, payload do |request|
25
- request.headers['Content-Type'] = 'application/json'
26
25
  request.headers['accept'] = 'application/json'
27
26
  end
28
27
 
29
- JSON.parse(response.body)
28
+ JSON.parse(response.body).try(:dig, "access_token")
30
29
  end
31
30
 
32
31
  def setup
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rail-locator-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.0.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov