rail-locator-api 0.1.18 → 0.1.19

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 52167f016f230777e3d7f8e262ae868434d5010e3ef07952559ebda36eae10a9
4
- data.tar.gz: e6fe8e8f21e9f044948f63ab0b8c8b41d7435d2bdaed26497d95ff8f77f9b1dd
3
+ metadata.gz: 20b440c61404c3936e6e761d66ebb53d8a2a64b05f3b0e73218541cfea98b304
4
+ data.tar.gz: 8d7cae49d86c17b95ab991a5e1656d03abf447b61f08462e222f5acfa9ce371a
5
5
  SHA512:
6
- metadata.gz: ab2ae71377ed90c81742e6fb852e6dfbc6d6a3e2e768a2609ac77f8b6256f75cfae469e52285c3c2160b13b1a3ef295848bd0bca6bc3064ceefccc7ed38ad955
7
- data.tar.gz: 42c4526305e430d5e15aea498b26de8de279e64c00547cfae93fc77951ddbbacdfce627f8c6c8383dbc98c5c20b68f9754bc47b056a62fcbaacf59e9c0c2b143
6
+ metadata.gz: f8ab04fcd867b26435610fdd0207d8518e82fe76e5dda2d02f084650e87b5f270da20d3258830230e9ad54759a022f6b8e23d3b7116f66d6b26ced7430038755
7
+ data.tar.gz: 3645f19709a8e38cc7c6a10214e8058a136bd71551363988e8e042c55763a7c233df8309cdad65eee262df71cbab410c5e65ace241978a637c5f3cb408589aa8
@@ -42,6 +42,10 @@ module RailLocatorApi
42
42
  @request_builder.refresh_token
43
43
  end
44
44
 
45
+ def api_user_id
46
+ @request_builder.api_user_id
47
+ end
48
+
45
49
  def api_key
46
50
  @request_builder.api_key
47
51
  end
@@ -140,6 +144,9 @@ module RailLocatorApi
140
144
  end
141
145
  if [:api_key].include?(self.api_auth_method)
142
146
  request.headers['X-API-KEY'] = "#{RailLocatorApi::Request.api_key}"
147
+ if self.api_user_id.present?
148
+ request.headers['X-USER-ID'] = self.api_user_id.to_s
149
+ end
143
150
  end
144
151
  request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
145
152
  if @request_builder.without_ratelimit
@@ -186,16 +193,16 @@ module RailLocatorApi
186
193
  def validate_api_key
187
194
  case self.api_auth_method
188
195
  when :api_key
189
- unless self.access_token && self.api_endpoint
190
- raise RailLocatorApi::RailLocatorApiError, "You must set an access_token prior to making a call #{self.access_token} #{self.api_endpoint}"
196
+ unless self.api_key && self.api_endpoint
197
+ raise RailLocatorApi::RailLocatorApiError, "You must set an api_key prior to making a call #{self.api_key} #{self.api_endpoint}"
191
198
  end
192
199
  when :base64
193
200
  unless self.api_user_email && self.api_user_password
194
201
  raise RailLocatorApi::RailLocatorApiError, "You must set an api_user_email and an api_user_password prior to making a call #{self.api_user_email} #{self.api_user_password} #{self.api_endpoint}"
195
202
  end
196
203
  when :keycloak
197
- unless self.api_user_email && self.api_user_password
198
- raise RailLocatorApi::RailLocatorApiError, "You must set an api_user_email and an api_user_password prior to making a call #{self.api_user_email} #{self.api_user_password} #{self.api_endpoint}"
204
+ unless self.access_token || self.refresh_token
205
+ raise RailLocatorApi::RailLocatorApiError, "You must set an access_token or a refresh_token prior to making a call #{self.access_token} #{self.refresh_token} #{self.api_endpoint}"
199
206
  end
200
207
  else
201
208
  raise RailLocatorApi::RailLocatorApiError, "You must set an api_auth_method prior to making a call #{self.api_auth_method} #{self.api_endpoint}"
@@ -1,6 +1,6 @@
1
1
  module RailLocatorApi
2
2
  class Request
3
- attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method, :api_endpoint,
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
5
  :without_ratelimit, :logger, :test
6
6
 
@@ -9,7 +9,7 @@ module RailLocatorApi
9
9
  DEFAULT_TIMEOUT = 60
10
10
  DEFAULT_OPEN_TIMEOUT = 60
11
11
 
12
- def initialize(access_token: nil, refresh_token: nil, api_key: nil, api_user_email: nil, api_user_password: nil,
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
14
  faraday_adapter: nil, symbolize_keys: false, debug: false, without_ratelimit: false,
15
15
  logger: nil, test: false)
@@ -18,6 +18,8 @@ module RailLocatorApi
18
18
  @api_key = api_key || self.class.api_key || ENV['RAIL_LOCATOR_API_KEY']
19
19
  @api_key = @api_key.strip if @api_key
20
20
 
21
+ @api_user_id = api_user_id
22
+
21
23
  @access_token = access_token || self.class.access_token || RailLocatorApi.generate_access_token.try(:dig, "access_token")
22
24
  @access_token = @access_token.strip if @access_token
23
25
  @refresh_token = refresh_token || self.class.refresh_token
@@ -106,12 +108,13 @@ module RailLocatorApi
106
108
  end
107
109
 
108
110
  class << self
109
- attr_accessor :access_token, :refresh_token, :api_key, :api_user_email, :api_user_password, :api_auth_method,
111
+ attr_accessor :access_token, :refresh_token, :api_user_id, :api_key, :api_user_email, :api_user_password, :api_auth_method,
110
112
  :timeout, :open_timeout, :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys,
111
113
  :debug, :without_ratelimit, :logger, :test
112
114
 
113
115
  def method_missing(sym, *args, &block)
114
116
  new(access_token: self.access_token, refresh_token: self.refresh_token,
117
+ api_user_id: self.api_user_id,
115
118
  api_key: self.api_key,
116
119
  api_user_email: self.api_user_email, api_user_password: self.api_user_email,
117
120
  api_auth_method: self.api_auth_method, api_endpoint: self.api_endpoint,
@@ -1,3 +1,3 @@
1
1
  module RailLocatorApi
2
- VERSION = "0.1.18"
2
+ VERSION = "0.1.19"
3
3
  end
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.1.18
4
+ version: 0.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov