json_requester 1.0.1 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/json_requester.rb +10 -7
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 467b682d40a325f12cc3d3978295045e12be336637097d3969ec56a3a328d0b9
|
4
|
+
data.tar.gz: c8555a3b99428168c237e77f213be694601e24e0bbf02c0c794eed322dfa4d92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2d301ffcaaacbd12ec3fa4ebb4d6a452efbee0ad153e2b8b46368c75cff203c5b7685b91ee9d242bf11195ce8b99448015e964881fe9d7cdadd9d30231c0be91
|
7
|
+
data.tar.gz: b6bfb90a49e3a58dea0caf47e99533041108991a8dde478ca89c859c85dece7051c1da3281973dc66b5307c00142fc16f0dd827adae23d7f696981183a92fbf5
|
data/README.md
CHANGED
data/lib/json_requester.rb
CHANGED
@@ -7,7 +7,6 @@ class JsonRequester
|
|
7
7
|
def initialize(host, multipart: false)
|
8
8
|
@host = host
|
9
9
|
@multipart = multipart
|
10
|
-
@conn = init_conn
|
11
10
|
end
|
12
11
|
|
13
12
|
def http_send(http_method, path, params={}, headers={})
|
@@ -19,7 +18,8 @@ class JsonRequester
|
|
19
18
|
end
|
20
19
|
|
21
20
|
def normal_send(http_method, path, params={}, headers={})
|
22
|
-
|
21
|
+
conn = init_conn
|
22
|
+
res = conn.send(http_method) do |req|
|
23
23
|
req.url path
|
24
24
|
req.headers = headers if object_present?(headers)
|
25
25
|
req.params = params if object_present?(params)
|
@@ -30,7 +30,8 @@ class JsonRequester
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def json_send(http_method, path, params={}, headers={})
|
33
|
-
|
33
|
+
conn = init_conn
|
34
|
+
res = conn.send(http_method) do |req|
|
34
35
|
req.url path
|
35
36
|
req.headers = headers if object_present?(headers)
|
36
37
|
req.headers['Content-Type'] = 'application/json;charset=utf-8'
|
@@ -42,7 +43,8 @@ class JsonRequester
|
|
42
43
|
end
|
43
44
|
|
44
45
|
def form_send(http_method, path, params={}, headers={})
|
45
|
-
|
46
|
+
conn = init_conn
|
47
|
+
res = conn.send(http_method) do |req|
|
46
48
|
req.url path
|
47
49
|
req.headers = headers if object_present?(headers)
|
48
50
|
req.headers['Content-Type'] = 'application/x-www-form-urlencoded ;charset=utf-8'
|
@@ -54,7 +56,8 @@ class JsonRequester
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def multipart_form_send(http_method, path, params={}, headers={})
|
57
|
-
|
59
|
+
conn = init_conn
|
60
|
+
res = conn.send(http_method) do |req|
|
58
61
|
req.url path
|
59
62
|
req.headers = headers if object_present?(headers)
|
60
63
|
req.body = params if object_present?(params)
|
@@ -78,7 +81,7 @@ class JsonRequester
|
|
78
81
|
begin
|
79
82
|
body = JSON.parse(response.body)
|
80
83
|
body = body.is_a?(Hash) ? body : {'body' => body}
|
81
|
-
body['body_status'] = body.delete('status') unless body['status'].
|
84
|
+
body['body_status'] = body.delete('status') unless body['status'].nil?
|
82
85
|
rescue
|
83
86
|
body = {'body' => response.body}
|
84
87
|
end
|
@@ -92,5 +95,5 @@ class JsonRequester
|
|
92
95
|
def object_present?(object)
|
93
96
|
!(object.nil? || object.empty?)
|
94
97
|
end
|
95
|
-
|
98
|
+
|
96
99
|
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json_requester
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JiaRou Lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: 1.0.0
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 1.0.0
|
27
27
|
description: wrapper of faraday
|