Module: Lenddo::Authentication

Defined in:
lib/lenddo/authentication.rb

Instance Method Summary collapse

Instance Method Details

#signed_request(args) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/lenddo/authentication.rb', line 8

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)
  Curl.send(method.to_s, uri.to_s, params) do |http|
    headers = sign(method.upcase, path, body)
    headers.each do |key, value|
      http.headers[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
end