client-api 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 46af95811a5c97fa979f9db48ca3823245458fb92c2a68985d7f97df8d13da4b
4
- data.tar.gz: a123355edfe6259438b07f7c3f39aa6587f85347633c41ac44494e3585588221
3
+ metadata.gz: f1afe0ff8d3a07ddb2e8050b8f8a39b10bf38faf35421a5ab12ff4996d04948c
4
+ data.tar.gz: 5f3ee93d0610dca08f0e8011f382d1208795478ebf8bda9e5060c67ba59d8c8a
5
5
  SHA512:
6
- metadata.gz: 21cd18b3c769375f019df20bec21807a37d083d091c6a53aa942a98a5b8ff91f12c313690abe9447e45ce4f6b42da80d554dd573c48d3dc61e1a95b340253847
7
- data.tar.gz: c89d2fb15dd961443ae9cb02d3811f4fb84f4dadb1801ed4257f300d4d5581f67b425a3e692bb8104ffb8ad26ba046fa4000f6b092261f5b1941e260b979a7a5
6
+ metadata.gz: 0fde562f2aaee46f7583188fe56eda1c13cfceb589cff5970127b2b267d2b42f1b9184293cd86348b9fb3fccf248ee32177bcecef0f1cd9bdbee2e9d6a77b180
7
+ data.tar.gz: fbde9845b6bd332a6b20c0a84f9d1e07d39fce1f38a539974b7269d00f014c095af85c6b55134042b551b1bc52ffa853d2388d3ee9d1354166ecdbcde03953be
@@ -11,13 +11,13 @@ module ClientApi
11
11
  end
12
12
 
13
13
  def get(url, headers = nil)
14
- @output = get_request(url, :headers => headers)
14
+ @output = get_request(url_generator(url), :headers => headers)
15
15
  self.post_logger if $logger
16
16
  self.output_json_body if json_output
17
17
  end
18
18
 
19
19
  def get_with_body(url, body = nil, headers = nil)
20
- @output = get_with_body_request(url, :body => body, :headers => headers)
20
+ @output = get_with_body_request(url_generator(url), :body => body, :headers => headers)
21
21
  self.post_logger if $logger
22
22
  self.output_json_body if json_output
23
23
  end
@@ -25,9 +25,9 @@ module ClientApi
25
25
  def post(url, body, headers = nil)
26
26
  if body.is_a? Hash
27
27
  if body['type'] && body['data']
28
- @output = post_request_x(url, :body => body, :headers => headers)
28
+ @output = post_request_x(url_generator(url), :body => body, :headers => headers)
29
29
  else
30
- @output = post_request(url, :body => body, :headers => headers)
30
+ @output = post_request(url_generator(url), :body => body, :headers => headers)
31
31
  end
32
32
  else
33
33
  raise 'invalid body'
@@ -38,19 +38,19 @@ module ClientApi
38
38
  end
39
39
 
40
40
  def delete(url, headers = nil)
41
- @output = delete_request(url, :headers => headers)
41
+ @output = delete_request(url_generator(url), :headers => headers)
42
42
  self.post_logger if $logger
43
43
  self.output_json_body if json_output
44
44
  end
45
45
 
46
46
  def put(url, body, headers = nil)
47
- @output = put_request(url, :body => body, :headers => headers)
47
+ @output = put_request(url_generator(url), :body => body, :headers => headers)
48
48
  self.post_logger if $logger
49
49
  self.output_json_body if json_output
50
50
  end
51
51
 
52
52
  def patch(url, body, headers = nil)
53
- @output = patch_request(url, :body => body, :headers => headers)
53
+ @output = patch_request(url_generator(url), :body => body, :headers => headers)
54
54
  self.post_logger if $logger
55
55
  self.output_json_body if json_output
56
56
  end
@@ -126,6 +126,24 @@ module ClientApi
126
126
  end
127
127
  end
128
128
 
129
+ def url_generator(url)
130
+ begin
131
+ if url.count == 2
132
+ raise('":url"'.green + ' field is missing in url'.red) if url[:url].nil?
133
+ raise('":query"'.green + ' field is missing in url'.red) if url[:query].nil?
134
+
135
+ query = url[:url].include?('?') ? [url[:url]] : [url[:url].concat('?')]
136
+
137
+ url[:query].map do |val|
138
+ query << val[0].to_s + "=" + val[1].gsub(' ','%20') + "&"
139
+ end
140
+ return query.join.delete_suffix('&')
141
+ end
142
+ rescue ArgumentError
143
+ url
144
+ end
145
+ end
146
+
129
147
  alias :schema_from_json :payload
130
148
 
131
149
  end
@@ -27,7 +27,7 @@ module ClientApi
27
27
  end
28
28
 
29
29
  def time_out
30
- ClientApi.configuration.time_out || ''
30
+ ClientApi.configuration.time_out || 60
31
31
  end
32
32
 
33
33
  end
@@ -1,3 +1,3 @@
1
1
  module ClientApi
2
- VERSION = "0.3.6".freeze
2
+ VERSION = "0.3.7".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.3.6
4
+ version: 0.3.7
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-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler