Skip to content

Commit 21e537f

Browse files
api client emulator working
1 parent aaf1d20 commit 21e537f

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

any_num_param.rb

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
def get_data(url, headers = {}, *params)
2+
puts "calling #{url}"
3+
if headers.length > 0
4+
puts "headers: #{headers}"
5+
else
6+
puts "no headers"
7+
end
8+
params.each do |param|
9+
puts "found param: #{param}"
10+
end
11+
end
12+
13+
def assemble_params(inlude_headers = false, include_date = false, only_show_my_records = true)
14+
headers = {accept: "application/json"}
15+
url = "https://exampleapi.com"
16+
args = [url]
17+
args << headers if inlude_headers
18+
params = []
19+
params << "date=#{Time.now}" if include_date
20+
params << "myrecords=true" if only_show_my_records
21+
args << params if params.length > 0
22+
end
23+
24+
# get_data(*assemble_params)
25+
# get_data(*assemble_params(true))
26+
get_data(*assemble_params(false,true,false))

0 commit comments

Comments
 (0)