api_gears 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/api_gears.rb +7 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f507faa2482f5d973b16cccbd1e571f3475251cd2bd905cccc3e56557c4eeb1
|
4
|
+
data.tar.gz: 16052d258d0e726758d00185999c6063b4ef9e05440406cdc4ff24d74714c9cc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 053a41ef2a760d158b8130b775357b32642b25e0bf5b5a61cb8c8dfc70f55b6925d3ce9af3e91b8e2238eb7013269f6059df87fb81e372535bd354c2d2b4216c
|
7
|
+
data.tar.gz: d48f6cfd3fb8e7a6d58d9917309bfaced0f51352269a37560d505b986ca5f48d20386753b53e8e2bb405c6f77d1a0930ad4da53dd6943e1eb6775a64fb2be40f
|
data/lib/api_gears.rb
CHANGED
@@ -214,7 +214,7 @@ class ApiGears
|
|
214
214
|
end
|
215
215
|
# Builds URL and args for a specific endpoint call
|
216
216
|
# @param endpoint [String] or [Symbol] the method name that has been called
|
217
|
-
# @param args [Hash] the args passed in during the method call
|
217
|
+
# @param args [Hash] the args passed in during the method call, when the required arg has 2 parts, (eg "book_id"), the first part of the arg name can be used (in this case "book" though this should only be used when "book" is unique in the query)
|
218
218
|
# @return [Hash] with url and query params
|
219
219
|
def url_for(endpoint, args)
|
220
220
|
url = @uri.dup
|
@@ -223,12 +223,15 @@ class ApiGears
|
|
223
223
|
|
224
224
|
if(!@endpoints[endpoint.to_sym][:args].nil? && @endpoints[endpoint.to_sym][:args].length > 0)
|
225
225
|
args_for(endpoint.to_sym).each do |arg|
|
226
|
-
|
226
|
+
specific_arg_not_found = (args[arg].nil?)
|
227
|
+
arg_has_two_parts = (arg.to_s.split("_").length == 2)
|
228
|
+
arg_shortcut_found = (!args[arg.to_s.split("_")[0].to_sym].nil?)
|
229
|
+
if(specific_arg_not_found && arg_has_two_parts && arg_shortcut_found )
|
227
230
|
value = args[arg.to_s.split("_")[0].to_sym]
|
228
231
|
else
|
229
232
|
value = args[arg]
|
230
233
|
end
|
231
|
-
e_path = e_path.gsub("{#{arg}}", value.to_s)
|
234
|
+
e_path = e_path.gsub("{#{arg.to_s}}", value.to_s)
|
232
235
|
end
|
233
236
|
end
|
234
237
|
|
@@ -249,6 +252,7 @@ class ApiGears
|
|
249
252
|
end
|
250
253
|
end
|
251
254
|
|
255
|
+
|
252
256
|
if(args[:query_method] == :GET)
|
253
257
|
url.query = URI.encode_www_form(query_set)
|
254
258
|
return {url:url,params:{}}
|