4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
# File 'lib/google-sa-auth/client.rb', line 4
def run(args)
args = args.inject({}){|item,(k,v)| item[k.to_sym] = v; item}
args = args.delete_if {|k,v| ![:uri, :data, :headers, :method].include?(k)}
args[:data] ||= {}
args[:headers] ||= {}
protocol, host, path = parse_uri(args[:uri])
host_info = {
:host => host,
:path => path,
:protocol => protocol,
:headers => args[:headers]
}
if args[:method] == 'get'
CurbFu.get(host_info, args[:data])
elsif args[:method] == 'post'
CurbFu.post(host_info, args[:data])
elsif args[:method] == 'put'
CurbFu.put(host_info, args[:data])
elsif args[:method] == 'delete'
CurbFu.delete(host_info, args[:data])
else
raise 'InvalidRequestType', "Unknown method: #{method}"
end
end
|