client-api 0.2.2 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8fd4db78496284c253a4fd5e2438fc766eb97982a982c31b0c9974867c2365f0
4
- data.tar.gz: 8c9734391ec74dfb0c128a3ee87d57bf5410ff8e4fd83ad57f07bf094f340a23
3
+ metadata.gz: 23ff29609a31f163d76a2e84ac9e3fd9bd834e555e159a03afd9556ea8ccea50
4
+ data.tar.gz: 586fd4d9b586635837eff93a46712d3055ba715748b72d0c06ffe197d9598189
5
5
  SHA512:
6
- metadata.gz: ffdd1155fdc2d5119cc3df470ccf4e15e43944961db63d9799b07c0434115e88256cdd8dcc832a96f56f6c7141e80b075b0fdf2c6439ca20bc73db48f542b13c
7
- data.tar.gz: be339ea1869403fb13476971b3975595ea4c2d229d259665cd24a60374c2871500754faa27ac60cda210fe2d20e02d9a89ffa831296e34e843b915d1363b1afa
6
+ metadata.gz: daeb105da0c461ee8f8c67f7673fd2409a814f90d7fe32e57ca4979d01f3efab420c2a6ecb8c0b31bf25012957d67a8ab3bcf6f2a1ec25e1cf28507921b2af42
7
+ data.tar.gz: 516c497e96c6604cc59855903fb0b7d7afd603fdcb2d87269f0572df9c76b3535d11cad1111c956ac25af429eace7d1db2fb66e1aae925ccfea52ec4378b37d5
@@ -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
 
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ClientApi
2
- VERSION = "0.2.2".freeze
2
+ VERSION = "0.2.3".freeze
3
3
  end
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.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-15 00:00:00.000000000 Z
11
+ date: 2019-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler