eezee 1.0.10 → 1.0.15
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +2 -1
- data/lib/eezee/client/requester.rb +12 -7
- data/lib/eezee/configuration.rb +4 -1
- data/lib/eezee/errors/request_error.rb +4 -3
- data/lib/eezee/request.rb +6 -2
- data/lib/eezee/request_error_factory.rb +2 -2
- data/lib/eezee/version.rb +1 -1
- metadata +6 -11
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0c5f98dff776c1b37d51964cb1fce7c6a1e68623a7e13dc210bfc5d85d16c12f
|
4
|
+
data.tar.gz: ce22ed7f4753802de69b1479e18a0cc93f6dee6e6073c319c15e90549670ea42
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b55295915cab2a6a44a0df55b6f6b8081373accfec020d655170374a04d53661708172788318a814d88e9412f6b76c6165c723a81620b690069a90e294a8fa64
|
7
|
+
data.tar.gz: 1c0fc574d0fcaf3f11a24013fc6b69912ffa832d5748bccbede924ecdd107bdc4b86d017e2b0e767f55cbed1b8061badd078115f0aa5aea8be022f030c43d71d
|
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -179,7 +179,8 @@ Here are the list of available options and about them:
|
|
179
179
|
| `raise_error` | No | `false` | If you want that Eezee raises an error if the request has wasn't successful. See more in [Errors](#errors) | `true` |
|
180
180
|
| `logger` | No | `false` | If you want to log the request, response, and error | `true` |
|
181
181
|
| `url_encoded` | No | `false` | If you want to send request body as form_url_encoded | `true` |
|
182
|
-
|
182
|
+
| `preserve_url_params` | No | `false` | The query params will be preserved if the url or path has a nested param like `:character_id` this value will be not replaced | `true` |
|
183
|
+
| `ddtrace` | No | `nil` | Support for [DataDog apm](http://gems.datadoghq.com/trace/docs/#Faraday) | `{}` |
|
183
184
|
|
184
185
|
### Services
|
185
186
|
|
@@ -28,7 +28,7 @@ module Eezee
|
|
28
28
|
.tap { |response| request.after!(request, response, nil) }
|
29
29
|
rescue Faraday::Error => e
|
30
30
|
response = Eezee::Response.new(e)
|
31
|
-
error = Eezee::RequestErrorFactory.build(response)
|
31
|
+
error = Eezee::RequestErrorFactory.build(request, response)
|
32
32
|
error.log if request.logger
|
33
33
|
return response if rescue_faraday_error?(request, response, error)
|
34
34
|
|
@@ -72,14 +72,19 @@ module Eezee
|
|
72
72
|
|
73
73
|
def build_faraday_client(request)
|
74
74
|
Faraday.new(request.uri) do |config|
|
75
|
-
config
|
76
|
-
config.use(Faraday::Response::RaiseError) if request.raise_error
|
77
|
-
config.headers = request.headers if request.headers
|
78
|
-
config.options[:open_timeout] = request.open_timeout if request.open_timeout
|
79
|
-
config.options[:timeout] = request.timeout if request.timeout
|
80
|
-
config.adapter(Faraday.default_adapter)
|
75
|
+
faraday_client_options!(config, request)
|
81
76
|
end
|
82
77
|
end
|
78
|
+
|
79
|
+
def faraday_client_options!(config, request)
|
80
|
+
config.request :url_encoded if request.url_encoded
|
81
|
+
config.use(Faraday::Response::RaiseError) if request.raise_error
|
82
|
+
config.headers = request.headers if request.headers
|
83
|
+
config.options[:open_timeout] = request.open_timeout if request.open_timeout
|
84
|
+
config.options[:timeout] = request.timeout if request.timeout
|
85
|
+
config.adapter(Faraday.default_adapter)
|
86
|
+
config.use(:ddtrace, request.ddtrace) if request.ddtrace.any?
|
87
|
+
end
|
83
88
|
end
|
84
89
|
end
|
85
90
|
end
|
data/lib/eezee/configuration.rb
CHANGED
@@ -19,7 +19,10 @@ module Eezee
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def request_by(request, options)
|
22
|
-
|
22
|
+
Marshal.dump(request&.attributes || {})
|
23
|
+
.then { |dumped| Marshal.load(dumped) } # rubocop:disable Security/MarshalLoad
|
24
|
+
.then { |attrs| attrs.merge(options || {}) }
|
25
|
+
.then { |attrs| Request.new(attrs) }
|
23
26
|
end
|
24
27
|
end
|
25
28
|
end
|
@@ -2,9 +2,10 @@
|
|
2
2
|
|
3
3
|
module Eezee
|
4
4
|
class RequestError < Error
|
5
|
-
attr_reader :response
|
5
|
+
attr_reader :response, :request
|
6
6
|
|
7
|
-
def initialize(response)
|
7
|
+
def initialize(request = nil, response = nil)
|
8
|
+
@request = request
|
8
9
|
@response = response
|
9
10
|
super(build_message)
|
10
11
|
end
|
@@ -16,7 +17,7 @@ module Eezee
|
|
16
17
|
private
|
17
18
|
|
18
19
|
def build_message
|
19
|
-
"CODE: #{@response
|
20
|
+
"CODE: #{@response&.code} - URI: #{@request&.uri} - BODY: #{@response&.body&.to_json}"
|
20
21
|
end
|
21
22
|
end
|
22
23
|
|
data/lib/eezee/request.rb
CHANGED
@@ -16,6 +16,8 @@ module Eezee
|
|
16
16
|
timeout
|
17
17
|
url
|
18
18
|
url_encoded
|
19
|
+
preserve_url_params
|
20
|
+
ddtrace
|
19
21
|
].freeze
|
20
22
|
|
21
23
|
DEFAULT = {
|
@@ -24,7 +26,9 @@ module Eezee
|
|
24
26
|
params: {},
|
25
27
|
payload: {},
|
26
28
|
raise_error: false,
|
27
|
-
url_encoded: false
|
29
|
+
url_encoded: false,
|
30
|
+
preserve_url_params: false,
|
31
|
+
ddtrace: {}
|
28
32
|
}.freeze
|
29
33
|
|
30
34
|
attr_accessor(*(ACCESSORS | %i[uri method]))
|
@@ -56,7 +60,7 @@ module Eezee
|
|
56
60
|
validate!
|
57
61
|
build_urn!
|
58
62
|
handle_query_params!
|
59
|
-
handle_urn_params!
|
63
|
+
handle_urn_params! unless @preserve_url_params
|
60
64
|
end
|
61
65
|
|
62
66
|
def hook!(hook, params)
|
@@ -3,10 +3,10 @@
|
|
3
3
|
module Eezee
|
4
4
|
class RequestErrorFactory
|
5
5
|
class << self
|
6
|
-
def build(response)
|
6
|
+
def build(request, response)
|
7
7
|
return TimeoutError.new(response) if response.timeout?
|
8
8
|
|
9
|
-
find_by_code(response.code).new(response)
|
9
|
+
find_by_code(response.code).new(request, response)
|
10
10
|
end
|
11
11
|
|
12
12
|
private
|
data/lib/eezee/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eezee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- linqueta
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-08-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -17,9 +17,6 @@ dependencies:
|
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 0.17.0
|
20
|
-
- - "~>"
|
21
|
-
- !ruby/object:Gem::Version
|
22
|
-
version: '0.17'
|
23
20
|
type: :runtime
|
24
21
|
prerelease: false
|
25
22
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -27,9 +24,6 @@ dependencies:
|
|
27
24
|
- - ">="
|
28
25
|
- !ruby/object:Gem::Version
|
29
26
|
version: 0.17.0
|
30
|
-
- - "~>"
|
31
|
-
- !ruby/object:Gem::Version
|
32
|
-
version: '0.17'
|
33
27
|
- !ruby/object:Gem::Dependency
|
34
28
|
name: bundler
|
35
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -239,6 +233,7 @@ executables: []
|
|
239
233
|
extensions: []
|
240
234
|
extra_rdoc_files: []
|
241
235
|
files:
|
236
|
+
- CHANGELOG.md
|
242
237
|
- MIT-LICENSE
|
243
238
|
- README.md
|
244
239
|
- lib/eezee.rb
|
@@ -261,7 +256,7 @@ homepage: https://github.com/linqueta/eezee
|
|
261
256
|
licenses:
|
262
257
|
- MIT
|
263
258
|
metadata: {}
|
264
|
-
post_install_message:
|
259
|
+
post_install_message:
|
265
260
|
rdoc_options: []
|
266
261
|
require_paths:
|
267
262
|
- lib
|
@@ -277,7 +272,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
272
|
version: '0'
|
278
273
|
requirements: []
|
279
274
|
rubygems_version: 3.0.3
|
280
|
-
signing_key:
|
275
|
+
signing_key:
|
281
276
|
specification_version: 4
|
282
277
|
summary: The easiest HTTP client for Ruby
|
283
278
|
test_files: []
|