rail-locator-api 1.0.0 → 1.0.2

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: ac2e0e239acbba6ce30a3dd36162bd219345078863b3cb930b03a1b43ccce9a8
4
- data.tar.gz: a34c66ebf1a4ecc622c819c8afdc162218d4c9b8944fbadc3e70790d17e28090
3
+ metadata.gz: a4b106056b806b72a8d99aee9870b884765f6fe6609648dc1f3cc7adbcd36b93
4
+ data.tar.gz: 4f5a0b0933558ee020fabaeca4f85703100bc426e44b96ff15e2134e5b47dd8a
5
5
  SHA512:
6
- metadata.gz: 8b9b022f9990122c8d689f9c7c7145627ffabf708bb29e28b17c865bbab663f403332c774a1b6af3cdb18d46e767f7a96478dd378bfbaa7ea63c23876cdf51db
7
- data.tar.gz: d55c58ff32c47f72e8f4e051033bc0fade804e1c63244180ae876bf0e0bc81da9632d5b36efd28335ce92e027e796884a100c049f41566e23b271bfa58c98bdd
6
+ metadata.gz: 142897bfde7720d2bcd04f2eaa8670af1e03390bd136cc72d7fea7cf3d927785fddd97e7ce4540342c98e743dca5347623b720177d7fd9332e423fb06acb902b
7
+ data.tar.gz: e8b7654f3bbc93309f087809f82b3b5ed7b4a6dda477830faec18981d59f3117cf0d672c806be55f03eae3af4bfaf0cdbfa5294bbc7f5adf82585da1463825bb
@@ -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: DEFAULT_TIMEOUT)
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 || DEFAULT_LANGUAGE
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.2"
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.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Osetrov