zaikio-client-helpers 0.3.0 → 0.5.0

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: a7c1175b44ca6b5ce9c35a6c24e3c2c546da668af38553303510b6e3ebb549f5
4
- data.tar.gz: 57f77bce22039beedee0f51da1ff1655dc3e602de987d3d13ce594337e5f37c0
3
+ metadata.gz: 3482f6dd1dfb10c58f9d4a72929cea46ef722268dae1f4141405f70d80be2ebf
4
+ data.tar.gz: 1284fa32bdae318ba56b9cb3d582f9ebc38c79399f3bdde7718d32f3fa381418
5
5
  SHA512:
6
- metadata.gz: 1eeb54b3661b5aa9d7730fa2751e1632273a63011cf3259f7db5df8228bd9b1208951b692332a54bf449750f1bde6ef8ea23f97d3927c896f96042a628e7d508
7
- data.tar.gz: a22972654c7b0a53f5844a7005d3afb08345cfab355d5493ff58c99fb2e28030f54854bc8bdb32aec118723470df0cd58d98ba101feaf1e04ff16f6295eceb3b
6
+ metadata.gz: c96cb10871f254378f764b966a5f2929594ad7ab2c9ec9a5141ca59f127d97e79bb2f42f1503d0cc48f03934f536f3c2370a40e48aa00729dc8f1858d6d45032
7
+ data.tar.gz: 0dbf79ca7bdfad2b1192f66bec9785123cedd3589288d2e4e185c00aa5cfa4647630129eb63eba9fe4320f4e6ee8fc09e911d4b2b335215d58040461a2f207a3
data/CHANGELOG.md CHANGED
@@ -1,4 +1,10 @@
1
- ## [Unreleased]
1
+ ## [0.5.0] - 2023-03-17
2
+
3
+ - Add new faraday middleware that automatically passes current `I18n.locale` to `Accept-Language` header
4
+
5
+ ## [0.4.0] - 2023-02-09
6
+
7
+ - Add a default read timeout for Faraday connection of 5 seconds, and open timeout of 1 second.
2
8
 
3
9
  ## [0.3.0] - 2022-08-15
4
10
 
@@ -4,7 +4,7 @@ module Zaikio
4
4
  module Client
5
5
  module Helpers
6
6
  class Configuration
7
- attr_accessor :host
7
+ attr_accessor :host, :disable_i18n
8
8
  attr_reader :environment
9
9
  attr_writer :logger
10
10
 
@@ -0,0 +1,22 @@
1
+ require "faraday"
2
+
3
+ module Zaikio
4
+ module Client
5
+ module Helpers
6
+ class LocaleMiddleware < Faraday::Middleware
7
+ def initialize(app, disable_i18n: false)
8
+ @disable_i18n = disable_i18n
9
+ super(app)
10
+ end
11
+
12
+ def call(request_env)
13
+ if !@disable_i18n && Object.const_defined?("I18n")
14
+ request_env[:request_headers]["Accept-Language"] = ::I18n.try(:locale)&.to_s
15
+ end
16
+
17
+ @app.call(request_env)
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -3,7 +3,7 @@
3
3
  module Zaikio
4
4
  module Client
5
5
  module Helpers
6
- VERSION = "0.3.0"
6
+ VERSION = "0.5.0"
7
7
  end
8
8
  end
9
9
  end
data/lib/zaikio/client.rb CHANGED
@@ -3,6 +3,7 @@ require "zaikio/client/helpers/json_parser"
3
3
  require "zaikio/client/helpers/pagination"
4
4
  require "zaikio/client/helpers/configuration"
5
5
  require "zaikio/client/helpers/authorization_middleware"
6
+ require "zaikio/client/helpers/locale_middleware"
6
7
 
7
8
  module Zaikio
8
9
  module Client
@@ -18,11 +19,14 @@ module Zaikio
18
19
  def create_connection(configuration)
19
20
  Faraday.new(url: configuration.host,
20
21
  ssl: { verify: configuration.environment != :test }) do |c|
22
+ c.options.read_timeout = 5
23
+ c.options.open_timeout = 1
21
24
  c.request :json
22
25
  c.response :logger, configuration&.logger, headers: false
23
26
  c.use Zaikio::Client::Helpers::Pagination::FaradayMiddleware
24
27
  c.use Zaikio::Client::Helpers::JSONParser
25
28
  c.use Zaikio::Client::Helpers::AuthorizationMiddleware
29
+ c.use Zaikio::Client::Helpers::LocaleMiddleware, disable_i18n: configuration.disable_i18n
26
30
  c.adapter Faraday.default_adapter
27
31
  end
28
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zaikio-client-helpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zaikio GMBH
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-08-15 00:00:00.000000000 Z
11
+ date: 2023-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -102,6 +102,7 @@ files:
102
102
  - lib/zaikio/client/helpers/authorization_middleware.rb
103
103
  - lib/zaikio/client/helpers/configuration.rb
104
104
  - lib/zaikio/client/helpers/json_parser.rb
105
+ - lib/zaikio/client/helpers/locale_middleware.rb
105
106
  - lib/zaikio/client/helpers/pagination.rb
106
107
  - lib/zaikio/client/helpers/version.rb
107
108
  - lib/zaikio/client/model.rb