module Vra::Http

Public Class Methods

error(response) click to toggle source
# File lib/vra/http.rb, line 21
def self.error(response)
  Error.from_response(response)
end
execute(params) click to toggle source
# File lib/vra/http.rb, line 7
def self.execute(params)
  request = Request.new(params)
  response = request.call
  response = response.forward(request).call until response.final?
  if ENV["VRA_HTTP_TRACE"]
    puts "#{request.params[:method].upcase} #{request.params[:url]}" unless request.params.nil?
    puts ">>>>> #{JSON.parse(request.params[:payload]).to_json.gsub(/\"password\":\"(.+)\",/, '"password":"********",' )}" unless request.params[:payload].nil?
    puts "<<<<< #{JSON.parse(response.body).to_json}" unless response.body.nil?
  end
  raise error(response) unless response.success?

  response
end