client-api 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/client-api/base.rb +16 -6
- data/lib/client-api/request.rb +5 -0
- data/lib/client-api/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23ff29609a31f163d76a2e84ac9e3fd9bd834e555e159a03afd9556ea8ccea50
|
4
|
+
data.tar.gz: 586fd4d9b586635837eff93a46712d3055ba715748b72d0c06ffe197d9598189
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daeb105da0c461ee8f8c67f7673fd2409a814f90d7fe32e57ca4979d01f3efab420c2a6ecb8c0b31bf25012957d67a8ab3bcf6f2a1ec25e1cf28507921b2af42
|
7
|
+
data.tar.gz: 516c497e96c6604cc59855903fb0b7d7afd603fdcb2d87269f0572df9c76b3535d11cad1111c956ac25af429eace7d1db2fb66e1aae925ccfea52ec4378b37d5
|
data/lib/client-api/base.rb
CHANGED
@@ -12,27 +12,32 @@ module ClientApi
|
|
12
12
|
|
13
13
|
def get(url, headers = nil)
|
14
14
|
@output = get_request(url, :headers => headers)
|
15
|
-
post_logger if $logger
|
15
|
+
self.post_logger if $logger
|
16
|
+
self.output_json_body if json_output
|
16
17
|
end
|
17
18
|
|
18
19
|
def post(url, body, headers = nil)
|
19
20
|
@output = post_request(url, :body => body, :headers => headers)
|
20
|
-
post_logger if $logger
|
21
|
+
self.post_logger if $logger
|
22
|
+
self.output_json_body if json_output
|
21
23
|
end
|
22
24
|
|
23
25
|
def delete(url, headers = nil)
|
24
26
|
@output = delete_request(url, :headers => headers)
|
25
|
-
post_logger if $logger
|
27
|
+
self.post_logger if $logger
|
28
|
+
self.output_json_body if json_output
|
26
29
|
end
|
27
30
|
|
28
31
|
def put(url, body, headers = nil)
|
29
32
|
@output = put_request(url, :body => body, :headers => headers)
|
30
|
-
post_logger if $logger
|
33
|
+
self.post_logger if $logger
|
34
|
+
self.output_json_body if json_output
|
31
35
|
end
|
32
36
|
|
33
37
|
def patch(url, body, headers = nil)
|
34
38
|
@output = patch_request(url, :body => body, :headers => headers)
|
35
|
-
post_logger if $logger
|
39
|
+
self.post_logger if $logger
|
40
|
+
self.output_json_body if json_output
|
36
41
|
end
|
37
42
|
|
38
43
|
def status
|
@@ -40,6 +45,12 @@ module ClientApi
|
|
40
45
|
end
|
41
46
|
|
42
47
|
def body
|
48
|
+
unless @output.body == "" || @output.body.nil? || @output.body == "{}"
|
49
|
+
JSON.parse(@output.body)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def output_json_body
|
43
54
|
unless @output.body == "" || @output.body.nil? || @output.body == "{}"
|
44
55
|
unless json_output['Dirname'] == nil
|
45
56
|
FileUtils.mkdir_p "#{json_output['Dirname']}"
|
@@ -50,7 +61,6 @@ module ClientApi
|
|
50
61
|
raise("\n"+" Not a compatible (or) Invalid JSON response => [kindly check the uri & request details]".brown + " \n\n #{e.message}")
|
51
62
|
end
|
52
63
|
end
|
53
|
-
JSON.parse(@output.body)
|
54
64
|
end
|
55
65
|
end
|
56
66
|
|
data/lib/client-api/request.rb
CHANGED
@@ -7,6 +7,11 @@ module ClientApi
|
|
7
7
|
|
8
8
|
include ClientApi
|
9
9
|
|
10
|
+
def initialize(scenario)
|
11
|
+
@scenario = scenario
|
12
|
+
$logger.debug("Requested scenario == '#{@scenario.description}'") if $logger
|
13
|
+
end
|
14
|
+
|
10
15
|
def get_request(url, options = {})
|
11
16
|
connect(url)
|
12
17
|
pre_logger(:log_url => uri(url), :log_header => header(options), :log_method => 'GET') if $logger
|
data/lib/client-api/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client-api
|
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
|
- Prashanth Sams
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-10-
|
11
|
+
date: 2019-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|