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
35
36
37
38
39
40
41
42
|
# File 'lib/lenddo/authentication.rb', line 9
def signed_request(args)
host = args[:host]
method = args[:method].downcase
path = args[:path]
params = args[:params]
if (method == 'post' || method == 'put')
body = params
else
body = {}
end
uri = URI.parse(host + path)
begin
response = Curl.send(method.to_s, uri.to_s, params) do |http|
= sign(method.upcase, path, body)
.each do |key, value|
http.[key] = value.chomp
end
http.use_ssl = 3
http.ssl_verify_host = OpenSSL::SSL::VERIFY_PEER
http.cacert = File.absolute_path("./cacert.pem") if RbConfig::CONFIG['host_os'] == 'mingw32'
end
rescue Curl::Err::TimeoutError => e
raise Lenddo::Errors::TimeoutException.new(e.message)
rescue Curl::Err::HostResolutionError => e
raise Lenddo::Errors::HostResolutionError.new(e.message)
rescue => e
raise Lenddo::Errors::UnknownException.new(e.message)
end
response
end
|