minato-utils 0.1.1 → 0.1.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 +4 -4
- data/Gemfile.lock +2 -2
- data/lib/minato/utils/client.rb +5 -4
- data/lib/minato/utils/response_handler.rb +8 -4
- data/lib/minato/utils/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 959e77004e8dcf1b83136526b298e078ad52ce0556822dd5b8c5ac89b8387b88
|
4
|
+
data.tar.gz: 0c4c96c0da914527cf0d1944d74b49d462350263014b5c50bd53366eb0587a8e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d9a4a715c8769add21b8bd40b897514bd42bcc3a70b9536d75badcca366502ef66cf8d202cb4baf00aff1a9e937dd5b024a512e5fa162cfcc94e98d74f417b7c
|
7
|
+
data.tar.gz: c832425e2775bd5c80e687a1f3b7cdc70ef45d28c7e65cb42a5e02a6399c6c58572858895ea651bad15ecc08dbe0a5826a912d57bf57ab3838fa3857446052ab
|
data/Gemfile.lock
CHANGED
data/lib/minato/utils/client.rb
CHANGED
@@ -18,8 +18,9 @@ module Minato
|
|
18
18
|
request(:get, path, options)
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
21
|
+
|
22
|
+
def post(path, options = {}, return_headers=false)
|
23
|
+
request(:post, path, options, return_headers)
|
23
24
|
end
|
24
25
|
|
25
26
|
def put(path, options = {})
|
@@ -36,7 +37,7 @@ module Minato
|
|
36
37
|
|
37
38
|
private
|
38
39
|
|
39
|
-
def request(method, path, options)
|
40
|
+
def request(method, path, options, return_header=false)
|
40
41
|
request_options = @default_options.deep_merge(options)
|
41
42
|
url = Minato::Utils::Helpers.join_url(@base_uri, path)
|
42
43
|
|
@@ -44,7 +45,7 @@ module Minato
|
|
44
45
|
response = self.class.send(method, url, request_options)
|
45
46
|
|
46
47
|
Minato::Utils.logger.log_response(method, @base_uri, path, request_options, response)
|
47
|
-
Minato::Utils::ResponseHandler.handle(response)
|
48
|
+
Minato::Utils::ResponseHandler.handle(response, return_header)
|
48
49
|
end
|
49
50
|
end
|
50
51
|
end
|
@@ -7,15 +7,19 @@ module Minato
|
|
7
7
|
module Utils
|
8
8
|
class ResponseHandler
|
9
9
|
class << self
|
10
|
-
def handle(response)
|
10
|
+
def handle(response, return_header=false)
|
11
11
|
raise_exception(response) if response_error?(response)
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
if(return_header)
|
14
|
+
{ body: Common::Utils.parse_json(response.body), header: response.header }
|
15
|
+
else
|
16
|
+
Minato::Utils::Helpers.parse_json(response.body)
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
private
|
17
21
|
|
18
|
-
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204].freeze
|
22
|
+
SUCCESSFUL_RESPONSE_CODE = [200, 201, 204, 302].freeze
|
19
23
|
|
20
24
|
EXCEPTION_HANDLERS_MAP = {
|
21
25
|
400 => 'bad_request',
|
data/lib/minato/utils/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ferreri
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -210,7 +210,7 @@ licenses:
|
|
210
210
|
- MIT
|
211
211
|
metadata:
|
212
212
|
rubygems_mfa_required: 'true'
|
213
|
-
post_install_message:
|
213
|
+
post_install_message:
|
214
214
|
rdoc_options: []
|
215
215
|
require_paths:
|
216
216
|
- lib
|
@@ -225,8 +225,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
225
225
|
- !ruby/object:Gem::Version
|
226
226
|
version: '0'
|
227
227
|
requirements: []
|
228
|
-
rubygems_version: 3.
|
229
|
-
signing_key:
|
228
|
+
rubygems_version: 3.2.32
|
229
|
+
signing_key:
|
230
230
|
specification_version: 4
|
231
231
|
summary: Minato Ruby Utils
|
232
232
|
test_files: []
|