eezee 1.0.9 → 1.0.10

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: c933960551337d50661fc40b0c38a7dfbec76ee7a63be6141c4c7a20a527ae3e
4
- data.tar.gz: a58390723f56e3a9b5d8ea38e38621b572db40f80eb3d1d01a0ff4356d238944
3
+ metadata.gz: f6f079b720f19b24847fb76fa83c1f574fac64babeaa84c64647570e7e43f37c
4
+ data.tar.gz: cc9f2f39e6e6e62d318fd1bd83efb828803838cbdab593c72f058c794f941a76
5
5
  SHA512:
6
- metadata.gz: 48863b10f2ccef3606f5185893f724d32c9447bec01c2e93a979c98fc5fa57541356d87d15fda2542c1abad87b4c6c17512e9e6ca1b6a47d3e7e3b4d879bc181
7
- data.tar.gz: c909bfdfcb9962e960871558ee18c0e8c633b3c8e034f07cfe2c70b385b599fb1715e56c037c280158aaeb3ae4c85a65de06ef98f1724efa8e86f29b958efc0e
6
+ metadata.gz: 274f2aa489f88193b05481084f06445130f5a9d1ddac9ec813712ce95c09fcdb280834a1a85fdb5816a0955c14d174f68ee68ecbe1f979ac252a0cc166efd953
7
+ data.tar.gz: bee96de51df0aa33613c561d4857b0e85a4644ed38816ea9765541f9c5cd9dd311351ca8f00c0a1ff969640e4a867299f658ef904a5ad9043416448ebe166690
data/README.md CHANGED
@@ -36,9 +36,7 @@ This gem is supported for Ruby 2.6+ applications.
36
36
  - [Examples](#examples)
37
37
  - [Complete integrations](#complete-integrations)
38
38
  - [Hooks](#hooks)
39
- - [Timeout](#timeout)
40
- - [Logging](#logging)
41
- - [Why use Eezee instead Faraday](#why-use-eezee-instead-faraday)
39
+ - [The why to use Eezee instead Faraday](#the-why-to-use-Eezee-instead-faraday)
42
40
  - [Contributing](#contributing)
43
41
  - [License](#license)
44
42
 
@@ -55,7 +53,7 @@ gem 'eezee'
55
53
  If you're on Rails you can run this line below to create the initializer:
56
54
 
57
55
  ```shell
58
- rails generator eezee:install
56
+ rails generate eezee:install
59
57
  ```
60
58
 
61
59
  ### Supported HTTP Methods
@@ -137,8 +135,8 @@ module RickMorty::Resource::Character
137
135
  extend Eezee::Client
138
136
 
139
137
  eezee_request_options protocol: :https,
140
- url: 'rickandmortyapi.com/api'
141
- path: 'character/:character_id'
138
+ url: 'rickandmortyapi.com/api'
139
+ path: 'character/:character_id'
142
140
 
143
141
  def self.index
144
142
  get
@@ -180,6 +178,8 @@ Here are the list of available options and about them:
180
178
  | `open_timeout` | No | `nil` | If it exceed this timeout to open a connection Eezee will raise the error `Eezee::TimeoutError` | `2` |
181
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` |
182
180
  | `logger` | No | `false` | If you want to log the request, response, and error | `true` |
181
+ | `url_encoded` | No | `false` | If you want to send request body as form_url_encoded | `true` |
182
+
183
183
 
184
184
  ### Services
185
185
 
@@ -289,17 +289,10 @@ Here are some examples:
289
289
 
290
290
  #### Hooks
291
291
 
292
- Coming soon...
293
-
294
- #### Timeout
295
-
296
- Coming soon...
297
-
298
- #### Logging
299
-
300
- Coming soon...
292
+ - [Adding a header into the request using before hook](https://gist.github.com/linqueta/badce27997df7a594bf0e87db858e225)
293
+ - [Handling resource not found errors using after hook](https://gist.github.com/linqueta/32bf5c12f23d2cb3e8d456e468892943)
301
294
 
302
- ## Why use Eezee instead Faraday
295
+ ## The why to use Eezee instead Faraday
303
296
 
304
297
  So, it's an important part of this README. This gem uses [Faraday](https://github.com/lostisland/faraday) as the HTTP client and Faraday is an excellent HTTP client, but it brings many difficult, or, in other words, many things could be easier, like:
305
298
 
@@ -59,12 +59,20 @@ module Eezee
59
59
 
60
60
  def build_faraday_request(req, client, method)
61
61
  client.send(method) do |faraday_req|
62
- faraday_req.body = req.payload.to_json if req.payload
62
+ build_faraday_request_body(faraday_req, req)
63
63
  end
64
64
  end
65
65
 
66
+ def build_faraday_request_body(faraday_req, req)
67
+ return unless req.payload
68
+
69
+ faraday_req.body = req.payload
70
+ faraday_req.body = faraday_req.body.to_json unless req.url_encoded
71
+ end
72
+
66
73
  def build_faraday_client(request)
67
74
  Faraday.new(request.uri) do |config|
75
+ config.request :url_encoded if request.url_encoded
68
76
  config.use(Faraday::Response::RaiseError) if request.raise_error
69
77
  config.headers = request.headers if request.headers
70
78
  config.options[:open_timeout] = request.open_timeout if request.open_timeout
@@ -15,6 +15,7 @@ module Eezee
15
15
  raise_error
16
16
  timeout
17
17
  url
18
+ url_encoded
18
19
  ].freeze
19
20
 
20
21
  DEFAULT = {
@@ -22,7 +23,8 @@ module Eezee
22
23
  logger: false,
23
24
  params: {},
24
25
  payload: {},
25
- raise_error: false
26
+ raise_error: false,
27
+ url_encoded: false
26
28
  }.freeze
27
29
 
28
30
  attr_accessor(*(ACCESSORS | %i[uri method]))
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Eezee
4
- VERSION = '1.0.9'
4
+ VERSION = '1.0.10'
5
5
  end
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.9
4
+ version: 1.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - linqueta
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2019-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday