rail-locator-api 1.0.0 → 1.0.1

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: ac2e0e239acbba6ce30a3dd36162bd219345078863b3cb930b03a1b43ccce9a8
4
- data.tar.gz: a34c66ebf1a4ecc622c819c8afdc162218d4c9b8944fbadc3e70790d17e28090
3
+ metadata.gz: b7eebc99961183efda1bff8d068595852179bbd79e9c3718b93f636d899b6ac5
4
+ data.tar.gz: c563e4a2d8e1ec6e4abcad31f0b2c979be6e831a4985a8d4f3e9fa5d40e5a2dd
5
5
  SHA512:
6
- metadata.gz: 8b9b022f9990122c8d689f9c7c7145627ffabf708bb29e28b17c865bbab663f403332c774a1b6af3cdb18d46e767f7a96478dd378bfbaa7ea63c23876cdf51db
7
- data.tar.gz: d55c58ff32c47f72e8f4e051033bc0fade804e1c63244180ae876bf0e0bc81da9632d5b36efd28335ce92e027e796884a100c049f41566e23b271bfa58c98bdd
6
+ metadata.gz: 207fcbee584148fe52fecf4b854e6fd0ee2706e63f2f97ac50e9457b4221f791e4a5b9301494a30b20d59722a699f89ac284434ee7342cccc130644f133eb122
7
+ data.tar.gz: ef96887e90a21bd57a274210c6edbd5cba4a97fc5410c9ac82f273e0a660211f2a6c5b462636efe4b49dc5b5cd9649729669aec923bdcd5972d84cad8eb9539f
@@ -18,5 +18,7 @@ RailLocatorApi.setup do |config|
18
18
  config::Request.symbolize_keys = true
19
19
  config::Request.debug = false
20
20
  config::Request.debug_options = { headers: true, bodies: false, errors: false, log_level: :info } # https://lostisland.github.io/faraday/middleware/logger
21
+
22
+ config::Requst.language = defined?(I18n) ? I18n.locale : :ru
21
23
  end
22
24
  end
@@ -157,6 +157,7 @@ module RailLocatorApi
157
157
  end
158
158
  end
159
159
  request.headers['User-Agent'] = "RailLocatorApi/#{RailLocatorApi::VERSION} Ruby gem"
160
+ request.headers['Accept-Language'] = RailLocatorApi::Request.language.to_s
160
161
  if @request_builder.without_ratelimit
161
162
  request.headers['X-Is-Request-Without-RateLimit'] = "true"
162
163
  end
@@ -2,19 +2,20 @@ 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, :debug_options,
5
- :without_ratelimit, :is_allow_access_to_coordinates, :logger, :test
5
+ :without_ratelimit, :is_allow_access_to_coordinates, :logger, :test, :language
6
6
 
7
7
  AUTH_METHODS = [:keycloak, :api_key, :base64]
8
8
  DEFAULT_AUTH_METHOD = :api_key
9
9
  DEFAULT_TIMEOUT = 60
10
10
  DEFAULT_OPEN_TIMEOUT = 60
11
+ DEFAULT_LANGUAGE = :ru
11
12
 
12
13
  def initialize(access_token: nil, refresh_token: nil, api_user_id: nil, api_key: nil, api_user_email: nil, api_user_password: nil,
13
14
  api_endpoint: nil, api_auth_method: nil, timeout: nil, open_timeout: nil, proxy: nil, ssl_options: nil,
14
15
  faraday_adapter: nil, symbolize_keys: false, debug: false,
15
16
  debug_options: { headers: true, bodies: false, errors: false, log_level: :info },
16
17
  without_ratelimit: false, is_allow_access_to_coordinates: false,
17
- logger: nil, test: false)
18
+ logger: nil, test: false, language: :ru)
18
19
 
19
20
  @path_parts = []
20
21
  @api_key = api_key || self.class.api_key || ENV['RAIL_LOCATOR_API_KEY']
@@ -48,6 +49,7 @@ module RailLocatorApi
48
49
  @without_ratelimit = without_ratelimit || self.class.without_ratelimit
49
50
  @is_allow_access_to_coordinates = is_allow_access_to_coordinates || self.class.is_allow_access_to_coordinates
50
51
  @test = test || self.class.test || false
52
+ @language = language || self.class.language || :ru
51
53
  @logger = logger || self.class.logger || ::Logger.new(STDOUT)
52
54
  end
53
55
 
@@ -123,7 +125,7 @@ module RailLocatorApi
123
125
  class << self
124
126
  attr_accessor :access_token, :refresh_token, :api_user_id, :api_key, :api_user_email, :api_user_password, :api_auth_method,
125
127
  :timeout, :open_timeout, :api_endpoint, :proxy, :ssl_options, :faraday_adapter, :symbolize_keys,
126
- :debug, :debug_options, :without_ratelimit, :is_allow_access_to_coordinates, :logger, :test
128
+ :debug, :debug_options, :without_ratelimit, :is_allow_access_to_coordinates, :logger, :test, :language
127
129
 
128
130
  def method_missing(sym, *args, &block)
129
131
  new(access_token: self.access_token, refresh_token: self.refresh_token,
@@ -136,7 +138,7 @@ module RailLocatorApi
136
138
  without_ratelimit: self.without_ratelimit,
137
139
  is_allow_access_to_coordinates: self.is_allow_access_to_coordinates,
138
140
  proxy: self.proxy, ssl_options: self.ssl_options, logger: self.logger,
139
- test: self.test).send(sym, *args, &block)
141
+ test: self.test, language: self.language).send(sym, *args, &block)
140
142
  end
141
143
 
142
144
  def respond_to_missing?(method_name, include_private = false)
@@ -1,3 +1,3 @@
1
1
  module RailLocatorApi
2
- VERSION = "1.0.0"
2
+ VERSION = "1.0.1"
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: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov