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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 48aef2f09600a7b19a47389354ea50c1aeb9a44e7e8e9ab7e7f5ba5b487d34cd
4
- data.tar.gz: d13b92f9d41a66b3ca8e4e2895b940792838d47cad52c9d522528db7fa969695
3
+ metadata.gz: dad7e7b83c16758623a09d848218d320f77256771df0665b296d9432b2cb85e4
4
+ data.tar.gz: 1f0ec5eeac0c08275c636d7c53344a19092c1794547b03369773f9e8957dc39a
5
5
  SHA512:
6
- metadata.gz: e9b47647147c6f312a07a50a77f1be26f4447afde89f68852599adedb6584c40f67c6a7e12ee5aad284d2a4f496d3368ae25eff87c1a101d507f6c4076f026f1
7
- data.tar.gz: e6e90c39214cc34b5fbec4d9e4f1697e8aec2a4e56d0a78fc6ee99d5609a1d4b1dfaa8e91b07a9e17a12cb7321458901037dc3caa403993b11fa5b67b37362ff
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, :logger, :test
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, logger: nil, test: 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, :timeout, :open_timeout,
97
- :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys, :debug, :logger, :test
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, proxy: self.proxy, ssl_options: self.ssl_options, logger: self.logger,
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
 
@@ -1,3 +1,3 @@
1
1
  module RailLocatorApi
2
- VERSION = "0.0.28"
2
+ VERSION = "0.0.32"
3
3
  end
@@ -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.access_token}&redirect_uri=#{RailLocatorApi.keycloak_redirect_uri}"
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
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.28
4
+ version: 0.0.32
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov