minato-utils 0.2.0 → 0.2.3
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 +4 -4
- data/.gitlab-ci.yml +1 -4
- data/Gemfile.lock +1 -1
- data/README.md +5 -5
- data/lib/minato/utils/client.rb +1 -2
- data/lib/minato/utils/response_handler.rb +5 -7
- data/lib/minato/utils/version.rb +1 -1
- data/release-notes.md +9 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a67141ad56404c902119ea4a8d6e8922416e3ec5005978a5f129ee7819a5af16
|
4
|
+
data.tar.gz: ed7a6709884e152c1a387537f7ab0a7c11eff66a51555cc288c18c68ca7c1aeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a86da77396744631e10d1f41b5acdb1de02e4ad35585ca3095cda795176e2ed4571160b588cd6d2cae15dcb0b3c09dac62a5c1db5fd75e5467794bf1bd8bfcd8
|
7
|
+
data.tar.gz: 847de42b62d239fe443f5e65dc28884c7feed3dfd0b95822523483a0a83f98a34ca7d059b162f74f22684e155d1c721949b1a734f215b94713c3dbdea00347d6
|
data/.gitlab-ci.yml
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -46,16 +46,16 @@ Para usar o cliente você vai precisar iniciar ele com `base_uri` e
|
|
46
46
|
client = Minato::Utils::Client.new(base_uri: 'http://www.test.com', default_options: headers: { 'Content-type' => 'application/json' })
|
47
47
|
```
|
48
48
|
|
49
|
-
Você pode usar todos os métodos HTTP para fazer requisições.
|
50
|
-
|
51
|
-
|
49
|
+
Você pode usar todos os métodos HTTP para fazer requisições. Além disso, é
|
50
|
+
possível adicionar mais opções ou sobrescrever o padrão usando o método
|
51
|
+
`params`:
|
52
52
|
|
53
53
|
```ruby
|
54
54
|
client.get('/path', headers: { 'X-Session-Token' => '123' })
|
55
55
|
```
|
56
56
|
|
57
|
-
As falhas de solicitação
|
58
|
-
As possíveis exceções são:
|
57
|
+
As falhas de solicitação produzirão uma exceção do tipo
|
58
|
+
`Minato::Utils::<Exception>`. As possíveis exceções são:
|
59
59
|
|
60
60
|
```ruby
|
61
61
|
Minato::Utils::BadRequest
|
data/lib/minato/utils/client.rb
CHANGED
@@ -37,7 +37,6 @@ module Minato
|
|
37
37
|
private
|
38
38
|
|
39
39
|
def request(method, path, options)
|
40
|
-
return_headers = options.delete(:return_headers)
|
41
40
|
request_options = @default_options.deep_merge(options)
|
42
41
|
url = Minato::Utils::Helpers.join_url(@base_uri, path)
|
43
42
|
|
@@ -45,7 +44,7 @@ module Minato
|
|
45
44
|
response = self.class.send(method, url, request_options)
|
46
45
|
|
47
46
|
Minato::Utils.logger.log_response(method, @base_uri, path, request_options, response)
|
48
|
-
Minato::Utils::ResponseHandler.handle(response
|
47
|
+
Minato::Utils::ResponseHandler.handle(response)
|
49
48
|
end
|
50
49
|
end
|
51
50
|
end
|
@@ -7,19 +7,17 @@ module Minato
|
|
7
7
|
module Utils
|
8
8
|
class ResponseHandler
|
9
9
|
class << self
|
10
|
-
def handle(response
|
10
|
+
def handle(response)
|
11
11
|
raise_exception(response) if response_error?(response)
|
12
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
Minato::Utils::Helpers.parse_json(response.body)
|
17
|
-
end
|
13
|
+
body = Minato::Utils::Helpers.parse_json(response.body)
|
14
|
+
header = response.header.to_hash || {}
|
15
|
+
{ body: body, header: header }
|
18
16
|
end
|
19
17
|
|
20
18
|
private
|
21
19
|
|
22
|
-
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204, 302].freeze
|
20
|
+
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204, 302, 303].freeze
|
23
21
|
|
24
22
|
EXCEPTION_HANDLERS_MAP = {
|
25
23
|
400 => 'bad_request',
|
data/lib/minato/utils/version.rb
CHANGED
data/release-notes.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
# Release Notes
|
2
2
|
|
3
|
+
## v0.2.2 - January 4th, 2022
|
4
|
+
|
5
|
+
### Compatibility Notes
|
6
|
+
|
7
|
+
- `return_headers` was removed from method `Minato::Utils::Client#request`<br/>
|
8
|
+
This renders `return_headers` as a hash key to `options` variable worthless, so
|
9
|
+
from now on you can assume that all requests will return a header regardless if
|
10
|
+
it's useful for the current invocation or not.
|
11
|
+
|
3
12
|
## v0.2.0 - December 20th, 2021
|
4
13
|
|
5
14
|
### Compatibility Notes
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: minato-utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -226,7 +226,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
226
226
|
- !ruby/object:Gem::Version
|
227
227
|
version: '0'
|
228
228
|
requirements: []
|
229
|
-
rubygems_version: 3.
|
229
|
+
rubygems_version: 3.1.6
|
230
230
|
signing_key:
|
231
231
|
specification_version: 4
|
232
232
|
summary: Minato Ruby Utils
|