rail-locator-api 0.1.19 → 0.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/rail-locator-api/api_request.rb +6 -3
- data/lib/rail-locator-api/request.rb +5 -3
- data/lib/rail-locator-api/version.rb +1 -1
- data/lib/rail-locator-api.rb +2 -2
- 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: 9988790e6c871a9ed969535f78ce48c313e68154fdc8a8a3844eee6b14350535
|
|
4
|
+
data.tar.gz: 26e58f6cbf89f73a7bddd60532325a5ed6571a899031db465d79252b524cdfd7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 8ad0802d88fe40ee719a4610efe1aa8d6db485014a240dc1e724cfbb8ce69574bdf9bd56f99ac23391ffe16a210d614b0438e0a2a077865cc51ebed4dd3b9492
|
|
7
|
+
data.tar.gz: e4a92fa709070d8d2f7130e3214e34a5efe5fc43a2b9707e74a069030689947ece8eb159ce54644b5fdbea65ba4d7dd35df71a43df6d6f86dfa0eec47551bbcc
|
|
@@ -143,14 +143,17 @@ module RailLocatorApi
|
|
|
143
143
|
request.headers['Authorization'] = "Bearer #{RailLocatorApi::Request.access_token}"
|
|
144
144
|
end
|
|
145
145
|
if [:api_key].include?(self.api_auth_method)
|
|
146
|
-
request.headers['X-
|
|
146
|
+
request.headers['X-Api-Key'] = "#{RailLocatorApi::Request.api_key}"
|
|
147
147
|
if self.api_user_id.present?
|
|
148
|
-
request.headers['X-
|
|
148
|
+
request.headers['X-User-Id'] = self.api_user_id.to_s
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
151
|
request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
|
|
152
152
|
if @request_builder.without_ratelimit
|
|
153
|
-
request.headers['X-Request-Without-Ratelimit'] = "
|
|
153
|
+
request.headers['X-Request-Without-Ratelimit'] = "true"
|
|
154
|
+
end
|
|
155
|
+
if @request_builder.is_allow_access_to_coordinates
|
|
156
|
+
request.headers['X_IS_ALLOW_ACCESS_TO_COORDINATES'] = "true"
|
|
154
157
|
end
|
|
155
158
|
request.headers.merge!(headers) if headers
|
|
156
159
|
request.body = MultiJson.dump(body) if body
|
|
@@ -2,7 +2,7 @@ module RailLocatorApi
|
|
|
2
2
|
class Request
|
|
3
3
|
attr_accessor :access_token, :refresh_token, :api_user_id, :api_key, :api_user_email, :api_user_password, :api_auth_method, :api_endpoint,
|
|
4
4
|
:timeout, :open_timeout, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug,
|
|
5
|
-
:without_ratelimit, :logger, :test
|
|
5
|
+
:without_ratelimit, :is_allow_access_to_coordinates, :logger, :test
|
|
6
6
|
|
|
7
7
|
AUTH_METHODS = [:keycloak, :api_key, :base64]
|
|
8
8
|
DEFAULT_AUTH_METHOD = :api_key
|
|
@@ -11,7 +11,7 @@ module RailLocatorApi
|
|
|
11
11
|
|
|
12
12
|
def initialize(access_token: nil, refresh_token: nil, api_user_id: nil, api_key: nil, api_user_email: nil, api_user_password: nil,
|
|
13
13
|
api_endpoint: nil, api_auth_method: nil, timeout: nil, open_timeout: nil, proxy: nil, ssl_options: nil,
|
|
14
|
-
faraday_adapter: nil, symbolize_keys: false, debug: false, without_ratelimit: false,
|
|
14
|
+
faraday_adapter: nil, symbolize_keys: false, debug: false, without_ratelimit: false, is_allow_access_to_coordinates: false,
|
|
15
15
|
logger: nil, test: false)
|
|
16
16
|
|
|
17
17
|
@path_parts = []
|
|
@@ -38,6 +38,7 @@ module RailLocatorApi
|
|
|
38
38
|
@symbolize_keys = symbolize_keys || self.class.symbolize_keys || false
|
|
39
39
|
@debug = debug || self.class.debug || false
|
|
40
40
|
@without_ratelimit = without_ratelimit || self.class.without_ratelimit
|
|
41
|
+
@is_allow_access_to_coordinates = is_allow_access_to_coordinates || self.class.is_allow_access_to_coordinates
|
|
41
42
|
@test = test || self.class.test || false
|
|
42
43
|
@logger = logger || self.class.logger || ::Logger.new(STDOUT)
|
|
43
44
|
end
|
|
@@ -110,7 +111,7 @@ module RailLocatorApi
|
|
|
110
111
|
class << self
|
|
111
112
|
attr_accessor :access_token, :refresh_token, :api_user_id, :api_key, :api_user_email, :api_user_password, :api_auth_method,
|
|
112
113
|
:timeout, :open_timeout, :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys,
|
|
113
|
-
:debug, :without_ratelimit, :logger, :test
|
|
114
|
+
:debug, :without_ratelimit, :is_allow_access_to_coordinates, :logger, :test
|
|
114
115
|
|
|
115
116
|
def method_missing(sym, *args, &block)
|
|
116
117
|
new(access_token: self.access_token, refresh_token: self.refresh_token,
|
|
@@ -120,6 +121,7 @@ module RailLocatorApi
|
|
|
120
121
|
api_auth_method: self.api_auth_method, api_endpoint: self.api_endpoint,
|
|
121
122
|
timeout: self.timeout, open_timeout: self.open_timeout, faraday_adapter: self.faraday_adapter,
|
|
122
123
|
symbolize_keys: self.symbolize_keys, debug: self.debug, without_ratelimit: self.without_ratelimit,
|
|
124
|
+
is_allow_access_to_coordinates: self.is_allow_access_to_coordinates,
|
|
123
125
|
proxy: self.proxy, ssl_options: self.ssl_options, logger: self.logger,
|
|
124
126
|
test: self.test).send(sym, *args, &block)
|
|
125
127
|
end
|
data/lib/rail-locator-api.rb
CHANGED
|
@@ -9,11 +9,11 @@ require 'rail-locator-api/response'
|
|
|
9
9
|
|
|
10
10
|
module RailLocatorApi
|
|
11
11
|
class << self
|
|
12
|
-
def generate_access_token
|
|
12
|
+
def generate_access_token(code=nil)
|
|
13
13
|
if RailLocatorApi.keycloak_grant_type == "password"
|
|
14
14
|
payload = "grant_type=#{RailLocatorApi.keycloak_grant_type}&client_id=#{RailLocatorApi.keycloak_client_id}&username=#{RailLocatorApi.api_user_email}&password=#{RailLocatorApi.api_user_password}"
|
|
15
15
|
else
|
|
16
|
-
payload = "grant_type=#{RailLocatorApi.keycloak_grant_type}&client_id=#{RailLocatorApi.keycloak_client_id}&client_secret=#{RailLocatorApi.keycloak_client_secret}&code=#{RailLocatorApi::Request.access_token}&redirect_uri=#{RailLocatorApi.keycloak_redirect_uri}"
|
|
16
|
+
payload = "grant_type=#{RailLocatorApi.keycloak_grant_type}&client_id=#{RailLocatorApi.keycloak_client_id}&client_secret=#{RailLocatorApi.keycloak_client_secret}&code=#{code ||RailLocatorApi::Request.access_token}&redirect_uri=#{RailLocatorApi.keycloak_redirect_uri}"
|
|
17
17
|
end
|
|
18
18
|
connection = Faraday.new(RailLocatorApi.keycloak_token_url, proxy: nil,
|
|
19
19
|
ssl: RailLocatorApi::Request.ssl_options || { version: "TLSv1_2" }) do |faraday|
|