Method: BOSSMan::REST.get

Defined in:
lib/bossman/rest.rb

.get(method, query, options) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/bossman/rest.rb', line 7

def self.get(method, query, options)
  validate_parameters(options)
  uri = URI.parse(URI.encode("#{API_BASEURI}/#{method}/#{API_VERSION}/#{query}"))
  uri.query = options.to_query
  request = Net::HTTP::Get.new(uri.request_uri)
  response = Net::HTTP.new(uri.host).request(request)

  case response
    when Net::HTTPSuccess
      return ResultSet.new(ActiveSupport::JSON.decode(response.body))
    else
      raise BOSSError, parse_error(response.body)
  end 
end