rail-locator-api 0.0.28 → 0.0.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rail-locator-api/api_request.rb +4 -0
- data/lib/rail-locator-api/request.rb +10 -5
- data/lib/rail-locator-api/version.rb +1 -1
- data/lib/rail-locator-api.rb +1 -1
- 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: dad7e7b83c16758623a09d848218d320f77256771df0665b296d9432b2cb85e4
|
4
|
+
data.tar.gz: 1f0ec5eeac0c08275c636d7c53344a19092c1794547b03369773f9e8957dc39a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: de50ad61ed19986b0ac61e9ae9e17e99e782b55e08972a11ebe916b737b6d713ac49e251ecbd795e480e3d88d9bc4beeee00707e0e95339fbd9428ffccac8624
|
7
|
+
data.tar.gz: 5c5192e82b74f2503ddc5099de920f6215f34bda55c91a79a975d8ad56be59d3a6484f2b38bb70fdc202c8caf8a4f5c1f1d1ca6981ee2b1511c0add182120e45
|
@@ -128,6 +128,10 @@ module RailLocatorApi
|
|
128
128
|
request.headers['Authorization'] = "Bearer #{RailLocatorApi::Request.access_token}"
|
129
129
|
end
|
130
130
|
request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
|
131
|
+
if @request_builder.without_ratelimit
|
132
|
+
request.headers['X-Request-Without-Ratelimit'] = "1"
|
133
|
+
end
|
134
|
+
|
131
135
|
request.headers.merge!(headers) if headers
|
132
136
|
request.body = MultiJson.dump(body) if body
|
133
137
|
request.options.timeout = self.timeout
|
@@ -1,7 +1,8 @@
|
|
1
1
|
module RailLocatorApi
|
2
2
|
class Request
|
3
3
|
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method, :api_endpoint,
|
4
|
-
:timeout, :open_timeout, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug,
|
4
|
+
:timeout, :open_timeout, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug,
|
5
|
+
:without_ratelimit, :logger, :test
|
5
6
|
|
6
7
|
AUTH_METHODS = [:keycloak, :api_key, :base64]
|
7
8
|
DEFAULT_AUTH_METHOD = :keycloak
|
@@ -10,7 +11,8 @@ module RailLocatorApi
|
|
10
11
|
|
11
12
|
def initialize(access_token: nil, refresh_token: nil, api_key: nil, api_user_email: nil, api_user_password: nil,
|
12
13
|
api_endpoint: nil, api_auth_method: nil, timeout: nil, open_timeout: nil, proxy: nil, ssl_options: nil,
|
13
|
-
faraday_adapter: nil, symbolize_keys: false, debug: false,
|
14
|
+
faraday_adapter: nil, symbolize_keys: false, debug: false, without_ratelimit: false,
|
15
|
+
logger: nil, test: false)
|
14
16
|
|
15
17
|
@path_parts = []
|
16
18
|
@api_key = api_key || self.class.api_key || ENV['RAIL_LOCATOR_API_KEY']
|
@@ -35,6 +37,7 @@ module RailLocatorApi
|
|
35
37
|
@faraday_adapter = faraday_adapter || self.class.faraday_adapter || Faraday.default_adapter
|
36
38
|
@symbolize_keys = symbolize_keys || self.class.symbolize_keys || false
|
37
39
|
@debug = debug || self.class.debug || false
|
40
|
+
@without_ratelimit = without_ratelimit || self.class.without_ratelimit
|
38
41
|
@test = test || self.class.test || false
|
39
42
|
@logger = logger || self.class.logger || ::Logger.new(STDOUT)
|
40
43
|
end
|
@@ -93,15 +96,17 @@ module RailLocatorApi
|
|
93
96
|
end
|
94
97
|
|
95
98
|
class << self
|
96
|
-
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method,
|
97
|
-
:
|
99
|
+
attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method,
|
100
|
+
:timeout, :open_timeout, :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys,
|
101
|
+
:debug, :without_ratelimit, :logger, :test
|
98
102
|
|
99
103
|
def method_missing(sym, *args, &block)
|
100
104
|
new(access_token: self.access_token, refresh_token: self.refresh_token, api_key: self.api_key,
|
101
105
|
api_user_email: self.api_user_email, api_user_password: self.api_user_email,
|
102
106
|
api_auth_method: self.api_auth_method, api_endpoint: self.api_endpoint,
|
103
107
|
timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter,
|
104
|
-
symbolize_keys: self.symbolize_keys, debug: self.debug,
|
108
|
+
symbolize_keys: self.symbolize_keys, debug: self.debug, without_ratelimit: self.without_ratelimit,
|
109
|
+
proxy: self.proxy, ssl_options: self.ssl_options, logger: self.logger,
|
105
110
|
test: self.test).send(sym, *args, &block)
|
106
111
|
end
|
107
112
|
|
data/lib/rail-locator-api.rb
CHANGED
@@ -28,7 +28,7 @@ module RailLocatorApi
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def refresh_access_token
|
31
|
-
payload = "grant_type=refresh_token&client_id=#{RailLocatorApi.keycloak_client_id}&client_secret=#{RailLocatorApi.keycloak_client_secret}&refresh_token=#{RailLocatorApi::Request.
|
31
|
+
payload = "grant_type=refresh_token&client_id=#{RailLocatorApi.keycloak_client_id}&client_secret=#{RailLocatorApi.keycloak_client_secret}&refresh_token=#{RailLocatorApi::Request.refresh_token}&redirect_uri=#{RailLocatorApi.keycloak_redirect_uri}"
|
32
32
|
connection = Faraday.new(RailLocatorApi.keycloak_token_url, proxy: nil,
|
33
33
|
ssl: { version: "TLSv1_2" }) do |faraday|
|
34
34
|
faraday.adapter Faraday.default_adapter
|