client-api-builder 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/Gemfile +1 -0
- data/Gemfile.lock +40 -28
- data/client-api-builder.gemspec +1 -1
- data/lib/client_api_builder/nested_router.rb +11 -7
- data/lib/client_api_builder/query_params.rb +31 -18
- data/lib/client_api_builder/router.rb +64 -41
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 201c8daf4abbc1489d26007b97c9b50145cffd98c699c2918d8f929138a1ef70
|
4
|
+
data.tar.gz: 627baef257a7d3a8037fa38eb5fa2e1c4f99f3ef0d191f083114f187e5690a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc3b8a34104099c0ab3bdcbf66c611286fe07841eac76e7d6ddbfebe5e97d5b374c0f52e9c47b3d9f1e49761ee0fca02565862875f48c932a31bd7d8f07543aa
|
7
|
+
data.tar.gz: 00216ed9808389eb0f41c9a084527f7311c1e13ad525945a2a920d39aca55e48c395471dd3bcb0ead25db8f6bb08f73f99693cc853e232534d298eff3bfbba31
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.
|
1
|
+
3.1.0
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,64 +1,76 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
+
activesupport (7.0.2.3)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
6
|
+
i18n (>= 1.6, < 2)
|
7
|
+
minitest (>= 5.1)
|
8
|
+
tzinfo (~> 2.0)
|
4
9
|
addressable (2.8.0)
|
5
10
|
public_suffix (>= 2.0.2, < 5.0)
|
6
11
|
ast (2.4.2)
|
12
|
+
concurrent-ruby (1.1.9)
|
7
13
|
crack (0.4.5)
|
8
14
|
rexml
|
9
|
-
diff-lcs (1.
|
15
|
+
diff-lcs (1.5.0)
|
10
16
|
docile (1.4.0)
|
11
17
|
hashdiff (1.0.1)
|
18
|
+
i18n (1.10.0)
|
19
|
+
concurrent-ruby (~> 1.0)
|
12
20
|
inheritance-helper (0.2.5)
|
13
|
-
|
14
|
-
|
21
|
+
minitest (5.15.0)
|
22
|
+
parallel (1.21.0)
|
23
|
+
parser (3.1.1.0)
|
15
24
|
ast (~> 2.4.1)
|
16
25
|
public_suffix (4.0.6)
|
17
|
-
rainbow (3.
|
18
|
-
rake (13.0.
|
19
|
-
regexp_parser (2.
|
26
|
+
rainbow (3.1.1)
|
27
|
+
rake (13.0.6)
|
28
|
+
regexp_parser (2.2.1)
|
20
29
|
rexml (3.2.5)
|
21
|
-
rspec (3.
|
22
|
-
rspec-core (~> 3.
|
23
|
-
rspec-expectations (~> 3.
|
24
|
-
rspec-mocks (~> 3.
|
25
|
-
rspec-core (3.
|
26
|
-
rspec-support (~> 3.
|
27
|
-
rspec-expectations (3.
|
30
|
+
rspec (3.11.0)
|
31
|
+
rspec-core (~> 3.11.0)
|
32
|
+
rspec-expectations (~> 3.11.0)
|
33
|
+
rspec-mocks (~> 3.11.0)
|
34
|
+
rspec-core (3.11.0)
|
35
|
+
rspec-support (~> 3.11.0)
|
36
|
+
rspec-expectations (3.11.0)
|
28
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
29
|
-
rspec-support (~> 3.
|
30
|
-
rspec-mocks (3.
|
38
|
+
rspec-support (~> 3.11.0)
|
39
|
+
rspec-mocks (3.11.0)
|
31
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
32
|
-
rspec-support (~> 3.
|
33
|
-
rspec-support (3.
|
34
|
-
rubocop (1.
|
41
|
+
rspec-support (~> 3.11.0)
|
42
|
+
rspec-support (3.11.0)
|
43
|
+
rubocop (1.26.0)
|
35
44
|
parallel (~> 1.10)
|
36
|
-
parser (>= 3.
|
45
|
+
parser (>= 3.1.0.0)
|
37
46
|
rainbow (>= 2.2.2, < 4.0)
|
38
47
|
regexp_parser (>= 1.8, < 3.0)
|
39
48
|
rexml
|
40
|
-
rubocop-ast (>= 1.
|
49
|
+
rubocop-ast (>= 1.16.0, < 2.0)
|
41
50
|
ruby-progressbar (~> 1.7)
|
42
51
|
unicode-display_width (>= 1.4.0, < 3.0)
|
43
|
-
rubocop-ast (1.
|
44
|
-
parser (>= 3.
|
52
|
+
rubocop-ast (1.16.0)
|
53
|
+
parser (>= 3.1.1.0)
|
45
54
|
ruby-progressbar (1.11.0)
|
46
55
|
simplecov (0.21.2)
|
47
56
|
docile (~> 1.1)
|
48
57
|
simplecov-html (~> 0.11)
|
49
58
|
simplecov_json_formatter (~> 0.1)
|
50
59
|
simplecov-html (0.12.3)
|
51
|
-
simplecov_json_formatter (0.1.
|
52
|
-
|
53
|
-
|
54
|
-
|
60
|
+
simplecov_json_formatter (0.1.4)
|
61
|
+
tzinfo (2.0.4)
|
62
|
+
concurrent-ruby (~> 1.0)
|
63
|
+
unicode-display_width (2.1.0)
|
64
|
+
webmock (3.14.0)
|
65
|
+
addressable (>= 2.8.0)
|
55
66
|
crack (>= 0.3.2)
|
56
67
|
hashdiff (>= 0.4.0, < 2.0.0)
|
57
68
|
|
58
69
|
PLATFORMS
|
59
|
-
x86_64-darwin-
|
70
|
+
x86_64-darwin-21
|
60
71
|
|
61
72
|
DEPENDENCIES
|
73
|
+
activesupport
|
62
74
|
inheritance-helper
|
63
75
|
rake
|
64
76
|
rspec
|
@@ -67,4 +79,4 @@ DEPENDENCIES
|
|
67
79
|
webmock
|
68
80
|
|
69
81
|
BUNDLED WITH
|
70
|
-
2.
|
82
|
+
2.3.3
|
data/client-api-builder.gemspec
CHANGED
@@ -34,8 +34,8 @@ module ClientApiBuilder
|
|
34
34
|
root_router.stream_to_file(**options, &block)
|
35
35
|
end
|
36
36
|
|
37
|
-
def base_url
|
38
|
-
self.class.base_url || root_router.base_url
|
37
|
+
def base_url
|
38
|
+
self.class.base_url || root_router.base_url
|
39
39
|
end
|
40
40
|
|
41
41
|
def build_headers(options)
|
@@ -52,7 +52,7 @@ module ClientApiBuilder
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
-
self.class.
|
55
|
+
self.class.default_headers.each(&add_header_proc)
|
56
56
|
|
57
57
|
headers
|
58
58
|
end
|
@@ -62,7 +62,7 @@ module ClientApiBuilder
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def build_query(query, options)
|
65
|
-
return nil if query.nil? && root_router.class.
|
65
|
+
return nil if query.nil? && root_router.class.default_query_params.empty? && self.class.default_query_params.empty?
|
66
66
|
|
67
67
|
query_params = {}
|
68
68
|
|
@@ -77,12 +77,12 @@ module ClientApiBuilder
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
root_router.class.
|
81
|
-
self.class.
|
80
|
+
root_router.class.default_query_params.each(&add_query_param_proc)
|
81
|
+
self.class.default_query_params.each(&add_query_param_proc)
|
82
82
|
query && query.each(&add_query_param_proc)
|
83
83
|
options[:query] && options[:query].each(&add_query_param_proc)
|
84
84
|
|
85
|
-
self.class.build_query(query_params)
|
85
|
+
self.class.build_query(self, query_params)
|
86
86
|
end
|
87
87
|
|
88
88
|
def build_body(body, options)
|
@@ -96,5 +96,9 @@ module ClientApiBuilder
|
|
96
96
|
def handle_response(response, options, &block)
|
97
97
|
root_router.handle_response(response, options, &block)
|
98
98
|
end
|
99
|
+
|
100
|
+
def escape_path(path)
|
101
|
+
root_router.escape_path(path)
|
102
|
+
end
|
99
103
|
end
|
100
104
|
end
|
@@ -2,59 +2,72 @@
|
|
2
2
|
require 'cgi'
|
3
3
|
|
4
4
|
module ClientApiBuilder
|
5
|
-
|
6
|
-
|
5
|
+
class QueryParams
|
6
|
+
attr_reader :name_value_separator,
|
7
|
+
:param_separator
|
7
8
|
|
8
|
-
|
9
|
+
attr_accessor :custom_escape_proc
|
10
|
+
|
11
|
+
def initialize(name_value_separator: '=', param_separator: '&', custom_escape_proc: nil)
|
12
|
+
@name_value_separator = name_value_separator
|
13
|
+
@param_separator = param_separator
|
14
|
+
@custom_escape_proc = custom_escape_proc
|
15
|
+
end
|
16
|
+
|
17
|
+
def to_query(data, namespace = nil)
|
9
18
|
case data
|
10
19
|
when Hash
|
11
|
-
to_query_from_hash(data, (namespace ?
|
20
|
+
to_query_from_hash(data, (namespace ? escape(namespace) : nil)).join(param_separator)
|
12
21
|
when Array
|
13
|
-
to_query_from_array(data, (namespace ? "#{
|
22
|
+
to_query_from_array(data, (namespace ? "#{escape(namespace)}[]" : '[]')).join(param_separator)
|
14
23
|
else
|
15
24
|
if namespace
|
16
|
-
"#{
|
25
|
+
"#{escape(namespace)}#{name_value_separator}#{escape(data.to_s)}"
|
17
26
|
else
|
18
|
-
|
27
|
+
escape(data.to_s)
|
19
28
|
end
|
20
29
|
end
|
21
30
|
end
|
22
31
|
|
23
|
-
def to_query_from_hash(hsh, namespace
|
32
|
+
def to_query_from_hash(hsh, namespace)
|
24
33
|
query_params = []
|
25
34
|
|
26
35
|
hsh.each do |key, value|
|
27
36
|
case value
|
28
37
|
when Array
|
29
|
-
array_namespace = namespace ? "#{namespace}[#{
|
30
|
-
query_params += to_query_from_array(value, array_namespace
|
38
|
+
array_namespace = namespace ? "#{namespace}[#{escape(key.to_s)}][]" : "#{escape(key.to_s)}[]"
|
39
|
+
query_params += to_query_from_array(value, array_namespace)
|
31
40
|
when Hash
|
32
|
-
hash_namespace = namespace ? "#{namespace}[#{
|
33
|
-
query_params += to_query_from_hash(value, hash_namespace
|
41
|
+
hash_namespace = namespace ? "#{namespace}[#{escape(key.to_s)}]" : "#{escape(key.to_s)}"
|
42
|
+
query_params += to_query_from_hash(value, hash_namespace)
|
34
43
|
else
|
35
|
-
query_name = namespace ? "#{namespace}[#{
|
36
|
-
query_params << "#{query_name}#{name_value_separator}#{
|
44
|
+
query_name = namespace ? "#{namespace}[#{escape(key.to_s)}]" : "#{escape(key.to_s)}"
|
45
|
+
query_params << "#{query_name}#{name_value_separator}#{escape(value.to_s)}"
|
37
46
|
end
|
38
47
|
end
|
39
48
|
|
40
49
|
query_params
|
41
50
|
end
|
42
51
|
|
43
|
-
def to_query_from_array(array, namespace
|
52
|
+
def to_query_from_array(array, namespace)
|
44
53
|
query_params = []
|
45
54
|
|
46
55
|
array.each do |value|
|
47
56
|
case value
|
48
57
|
when Hash
|
49
|
-
query_params += to_query_from_hash(value, namespace
|
58
|
+
query_params += to_query_from_hash(value, namespace)
|
50
59
|
when Array
|
51
|
-
query_params += to_query_from_array(value, "#{namespace}[]"
|
60
|
+
query_params += to_query_from_array(value, "#{namespace}[]")
|
52
61
|
else
|
53
|
-
query_params << "#{namespace}#{name_value_separator}#{
|
62
|
+
query_params << "#{namespace}#{name_value_separator}#{escape(value.to_s)}"
|
54
63
|
end
|
55
64
|
end
|
56
65
|
|
57
66
|
query_params
|
58
67
|
end
|
68
|
+
|
69
|
+
def escape(str)
|
70
|
+
custom_escape_proc ? custom_escape_proc.call(str) : CGI.escape(str)
|
71
|
+
end
|
59
72
|
end
|
60
73
|
end
|
@@ -30,93 +30,106 @@ module ClientApiBuilder
|
|
30
30
|
}.freeze
|
31
31
|
end
|
32
32
|
|
33
|
-
|
34
|
-
def
|
33
|
+
# tracks the proc used to handle responses
|
34
|
+
def add_response_proc(method_name, proc)
|
35
35
|
response_procs = default_options[:response_procs].dup
|
36
36
|
response_procs[method_name] = proc
|
37
37
|
add_value_to_class_method(:default_options, response_procs: response_procs)
|
38
38
|
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
40
|
+
# retrieves the proc used to handle the response
|
41
|
+
def get_response_proc(method_name)
|
42
|
+
default_options[:response_procs][method_name]
|
43
43
|
end
|
44
44
|
|
45
|
+
# set/get base url
|
45
46
|
def base_url(url = nil)
|
46
47
|
return default_options[:base_url] unless url
|
47
48
|
|
48
49
|
add_value_to_class_method(:default_options, base_url: url)
|
49
50
|
end
|
50
51
|
|
51
|
-
|
52
|
-
|
52
|
+
# set the builder to :to_json, :to_query, :query_params or specify a proc to handle building the request body payload
|
53
|
+
# or get the body builder
|
54
|
+
def body_builder(builder = nil, &block)
|
55
|
+
return default_options[:body_builder] if builder.nil? && block.nil?
|
53
56
|
|
54
|
-
add_value_to_class_method(:default_options, body_builder: builder)
|
57
|
+
add_value_to_class_method(:default_options, body_builder: builder || block)
|
55
58
|
end
|
56
59
|
|
57
|
-
|
58
|
-
|
60
|
+
# set the builder to :to_query, :query_params or specify a proc to handle building the request query params
|
61
|
+
# or get the query builder
|
62
|
+
def query_builder(builder = nil, &block)
|
63
|
+
return default_options[:query_builder] if builder.nil? && block.nil?
|
59
64
|
|
60
|
-
add_value_to_class_method(:default_options, query_builder: builder)
|
65
|
+
add_value_to_class_method(:default_options, query_builder: builder || block)
|
61
66
|
end
|
62
67
|
|
68
|
+
# add a request header
|
63
69
|
def header(name, value = nil, &block)
|
64
70
|
headers = default_options[:headers].dup
|
65
71
|
headers[name] = value || block
|
66
72
|
add_value_to_class_method(:default_options, headers: headers)
|
67
73
|
end
|
68
74
|
|
75
|
+
# set a connection_option, specific to Net::HTTP
|
69
76
|
def connection_option(name, value)
|
70
77
|
connection_options = default_options[:connection_options].dup
|
71
78
|
connection_options[name] = value
|
72
79
|
add_value_to_class_method(:default_options, connection_options: connection_options)
|
73
80
|
end
|
74
81
|
|
82
|
+
# add a query param to all requests
|
75
83
|
def query_param(name, value = nil, &block)
|
76
84
|
query_params = default_options[:query_params].dup
|
77
85
|
query_params[name] = value || block
|
78
86
|
add_value_to_class_method(:default_options, query_params: query_params)
|
79
87
|
end
|
80
88
|
|
81
|
-
|
89
|
+
# get default headers
|
90
|
+
def default_headers
|
82
91
|
default_options[:headers]
|
83
92
|
end
|
84
93
|
|
85
|
-
|
94
|
+
# get configured connection_options
|
95
|
+
def default_connection_options
|
86
96
|
default_options[:connection_options]
|
87
97
|
end
|
88
98
|
|
89
|
-
|
99
|
+
# get default query_params to add to all requests
|
100
|
+
def default_query_params
|
90
101
|
default_options[:query_params]
|
91
102
|
end
|
92
103
|
|
93
|
-
def build_body(router, body
|
94
|
-
|
95
|
-
|
96
|
-
case builder
|
104
|
+
def build_body(router, body)
|
105
|
+
case body_builder
|
97
106
|
when :to_json
|
98
107
|
body.to_json
|
99
108
|
when :to_query
|
100
109
|
body.to_query
|
101
110
|
when :query_params
|
102
|
-
ClientApiBuilder::QueryParams.to_query(body)
|
111
|
+
ClientApiBuilder::QueryParams.new.to_query(body)
|
112
|
+
when Symbol
|
113
|
+
router.send(body_builder, body)
|
103
114
|
else
|
104
|
-
router.instance_exec(body, &
|
115
|
+
router.instance_exec(body, &body_builder)
|
105
116
|
end
|
106
117
|
end
|
107
118
|
|
108
|
-
def build_query(query)
|
119
|
+
def build_query(router, query)
|
109
120
|
case query_builder
|
110
121
|
when :to_query
|
111
122
|
query.to_query
|
112
123
|
when :query_params
|
113
|
-
ClientApiBuilder::QueryParams.to_query(query)
|
124
|
+
ClientApiBuilder::QueryParams.new.to_query(query)
|
125
|
+
when Symbol
|
126
|
+
router.send(query_builder, query)
|
114
127
|
else
|
115
|
-
|
128
|
+
router.instance_exec(query, &query_builder)
|
116
129
|
end
|
117
130
|
end
|
118
131
|
|
119
|
-
def
|
132
|
+
def auto_detect_http_method(method_name)
|
120
133
|
case method_name.to_s
|
121
134
|
when /^(?:post|create|add|insert)/i
|
122
135
|
:post
|
@@ -172,6 +185,7 @@ module ClientApiBuilder
|
|
172
185
|
arguments
|
173
186
|
end
|
174
187
|
|
188
|
+
# returns a list of arguments to add to the route method
|
175
189
|
def get_arguments(value)
|
176
190
|
case value
|
177
191
|
when Hash
|
@@ -184,7 +198,7 @@ module ClientApiBuilder
|
|
184
198
|
end
|
185
199
|
|
186
200
|
def get_instance_method(var)
|
187
|
-
"#\{#{var}\}"
|
201
|
+
"#\{escape_path(#{var})\}"
|
188
202
|
end
|
189
203
|
|
190
204
|
@@namespaces = []
|
@@ -192,6 +206,7 @@ module ClientApiBuilder
|
|
192
206
|
@@namespaces
|
193
207
|
end
|
194
208
|
|
209
|
+
# a namespace is a top level path to apply to all routes within the namespace block
|
195
210
|
def namespace(name)
|
196
211
|
namespaces << name
|
197
212
|
yield
|
@@ -199,7 +214,7 @@ module ClientApiBuilder
|
|
199
214
|
end
|
200
215
|
|
201
216
|
def generate_route_code(method_name, path, options = {})
|
202
|
-
http_method = options[:method] ||
|
217
|
+
http_method = options[:method] || auto_detect_http_method(method_name)
|
203
218
|
|
204
219
|
path = namespaces.join + path
|
205
220
|
|
@@ -211,7 +226,7 @@ module ClientApiBuilder
|
|
211
226
|
path_arguments = []
|
212
227
|
path.gsub!(/:([a-z0-9_]+)/i) do |_|
|
213
228
|
path_arguments << $1
|
214
|
-
"#\{#{$1}\}"
|
229
|
+
"#\{escape_path(#{$1})\}"
|
215
230
|
end
|
216
231
|
|
217
232
|
has_body_param = options[:body].nil? && requires_body?(http_method, options)
|
@@ -268,12 +283,10 @@ module ClientApiBuilder
|
|
268
283
|
method_args += ["#{stream_param}:"] if stream_param
|
269
284
|
method_args += ['**__options__', '&block']
|
270
285
|
|
271
|
-
code = "def #{method_name}(" + method_args.join(', ') + ")\n"
|
272
|
-
code += " block ||= self.class.response_proc(#{method_name.inspect})\n"
|
286
|
+
code = "def #{method_name}_raw_response(" + method_args.join(', ') + ")\n"
|
273
287
|
code += " __path__ = \"#{path}\"\n"
|
274
288
|
code += " __query__ = #{query}\n"
|
275
289
|
code += " __body__ = #{body}\n"
|
276
|
-
code += " __expected_response_codes__ = #{expected_response_codes.inspect}\n"
|
277
290
|
code += " __uri__ = build_uri(__path__, __query__, __options__)\n"
|
278
291
|
code += " __body__ = build_body(__body__, __options__)\n"
|
279
292
|
code += " __headers__ = build_headers(__options__)\n"
|
@@ -292,7 +305,13 @@ module ClientApiBuilder
|
|
292
305
|
else
|
293
306
|
code += " @response = request(**@request_options)\n"
|
294
307
|
end
|
308
|
+
code += "end\n"
|
309
|
+
code += "\n"
|
295
310
|
|
311
|
+
code += "def #{method_name}(" + method_args.join(', ') + ")\n"
|
312
|
+
code += " block ||= self.class.get_response_proc(#{method_name.inspect})\n"
|
313
|
+
code += " __expected_response_codes__ = #{expected_response_codes.inspect}\n"
|
314
|
+
code += " #{method_name}_raw_response(" + method_args.map { |a| a =~ /:$/ ? "#{a} #{a.sub(':', '')}" : a }.join(', ') + ")\n"
|
296
315
|
code += " expected_response_code!(@response, __expected_response_codes__, __options__)\n"
|
297
316
|
|
298
317
|
if options[:stream] || options[:return] == :response
|
@@ -308,14 +327,14 @@ module ClientApiBuilder
|
|
308
327
|
end
|
309
328
|
|
310
329
|
def route(method_name, path, options = {}, &block)
|
311
|
-
|
330
|
+
add_response_proc(method_name, block) if block
|
312
331
|
|
313
332
|
self.class_eval generate_route_code(method_name, path, options), __FILE__, __LINE__
|
314
333
|
end
|
315
334
|
end
|
316
335
|
|
317
|
-
def base_url
|
318
|
-
|
336
|
+
def base_url
|
337
|
+
self.class.base_url
|
319
338
|
end
|
320
339
|
|
321
340
|
def build_headers(options)
|
@@ -332,7 +351,7 @@ module ClientApiBuilder
|
|
332
351
|
end
|
333
352
|
end
|
334
353
|
|
335
|
-
self.class.
|
354
|
+
self.class.default_headers.each(&add_header_proc)
|
336
355
|
options[:headers] && options[:headers].each(&add_header_proc)
|
337
356
|
|
338
357
|
headers
|
@@ -340,14 +359,14 @@ module ClientApiBuilder
|
|
340
359
|
|
341
360
|
def build_connection_options(options)
|
342
361
|
if options[:connection_options]
|
343
|
-
self.class.
|
362
|
+
self.class.default_connection_options.merge(options[:connection_options])
|
344
363
|
else
|
345
|
-
self.class.
|
364
|
+
self.class.default_connection_options
|
346
365
|
end
|
347
366
|
end
|
348
367
|
|
349
368
|
def build_query(query, options)
|
350
|
-
return nil if query.nil? && self.class.
|
369
|
+
return nil if query.nil? && self.class.default_query_params.empty?
|
351
370
|
|
352
371
|
query_params = {}
|
353
372
|
|
@@ -362,11 +381,11 @@ module ClientApiBuilder
|
|
362
381
|
end
|
363
382
|
end
|
364
383
|
|
365
|
-
self.class.
|
384
|
+
self.class.default_query_params.each(&add_query_param_proc)
|
366
385
|
query && query.each(&add_query_param_proc)
|
367
386
|
options[:query] && options[:query].each(&add_query_param_proc)
|
368
387
|
|
369
|
-
self.class.build_query(query_params)
|
388
|
+
self.class.build_query(self, query_params)
|
370
389
|
end
|
371
390
|
|
372
391
|
def build_body(body, options)
|
@@ -375,11 +394,11 @@ module ClientApiBuilder
|
|
375
394
|
return nil unless body
|
376
395
|
return body if body.is_a?(String)
|
377
396
|
|
378
|
-
self.class.build_body(self, body
|
397
|
+
self.class.build_body(self, body)
|
379
398
|
end
|
380
399
|
|
381
400
|
def build_uri(path, query, options)
|
382
|
-
uri = URI(base_url
|
401
|
+
uri = URI(base_url + path)
|
383
402
|
uri.query = build_query(query, options)
|
384
403
|
uri
|
385
404
|
end
|
@@ -416,5 +435,9 @@ module ClientApiBuilder
|
|
416
435
|
def root_router
|
417
436
|
self
|
418
437
|
end
|
438
|
+
|
439
|
+
def escape_path(path)
|
440
|
+
path
|
441
|
+
end
|
419
442
|
end
|
420
443
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: client-api-builder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Doug Youch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: inheritance-helper
|
@@ -66,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
rubygems_version: 3.
|
69
|
+
rubygems_version: 3.3.3
|
70
70
|
signing_key:
|
71
71
|
specification_version: 4
|
72
72
|
summary: Develop Client API libraries faster
|