json_requester 1.0.2 → 1.0.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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/json_requester.rb +8 -5
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21eaf675a4c5ed77b6eea64f37717038e2c82627f399423dd20a1452fa62be5e
4
- data.tar.gz: d2fe47889d68c4a1e8c03af212359de1273117a3286adced729515a40acbe4b4
3
+ metadata.gz: a2d4ed52990f4aef4fdf9e2cd0648f005e7470e0b9589f32318c89446e9fbbab
4
+ data.tar.gz: 2aa352620aa571c8b19dcdf556bba9e89f6ffc5c3c515d772f7bd2b0788a4f9c
5
5
  SHA512:
6
- metadata.gz: 316d952a76c2003e82c9d9082fb5c75aca54f45e4ac815fcf04516dbc6a5c960e8e5743e7c1a08f051b6bd23c9cbd005c3514e513963fe0ae87d3b2aaa065685
7
- data.tar.gz: b043b90e1469c34655138c5175a6b90d6c1d7e64db58da9c04f03caa66612ad507840573d19c86e177c567016ddeff4bb03efda7177b692d1d2992564b13c343
6
+ metadata.gz: 1872fdb58e459b0086a37106bfc654cacd05807a0c81992be6ef8ab51ec58dd938d08698d03216b78918cdf1ecac3ce1fcdb96870670854f3d9895c45d9e7d0e
7
+ data.tar.gz: 95237fb35a77e6c4d3c7347ebfc1e0ef1435f67adab10a7966549187cda6e1af60562ba91b8fe974dfb2a6dff046af8511916c5dd124c64f547c55b6254b0653
@@ -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
- res = @conn.send(http_method) do |req|
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
- res = @conn.send(http_method) do |req|
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
- res = @conn.send(http_method) do |req|
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
- res = @conn.send(http_method) do |req|
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)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json_requester
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JiaRou Lee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-05 00:00:00.000000000 Z
11
+ date: 2021-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday