client-api 0.3.6 → 0.3.7
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 +4 -4
- data/lib/client-api/base.rb +25 -7
- data/lib/client-api/settings.rb +1 -1
- 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: f1afe0ff8d3a07ddb2e8050b8f8a39b10bf38faf35421a5ab12ff4996d04948c
|
4
|
+
data.tar.gz: 5f3ee93d0610dca08f0e8011f382d1208795478ebf8bda9e5060c67ba59d8c8a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fde562f2aaee46f7583188fe56eda1c13cfceb589cff5970127b2b267d2b42f1b9184293cd86348b9fb3fccf248ee32177bcecef0f1cd9bdbee2e9d6a77b180
|
7
|
+
data.tar.gz: fbde9845b6bd332a6b20c0a84f9d1e07d39fce1f38a539974b7269d00f014c095af85c6b55134042b551b1bc52ffa853d2388d3ee9d1354166ecdbcde03953be
|
data/lib/client-api/base.rb
CHANGED
@@ -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
|
data/lib/client-api/settings.rb
CHANGED
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.3.
|
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
|
+
date: 2019-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|