Class: Itrigga::NetHelper::RestClient

Inherits:
Object
  • Object
show all
Defined in:
lib/itrigga/net_helper/rest_client.rb

Class Method Summary collapse

Class Method Details

.get(opts = {}) ⇒ Object

Raises:

  • (ArgumentError)


5
6
7
8
9
10
11
12
13
14
15
# File 'lib/itrigga/net_helper/rest_client.rb', line 5

def self.get( opts={} )
  raise ArgumentError.new(":url is required") unless opts[:url]
  
  # rest_client expects :user and not :username
  opts[:user] ||= opts.delete(:username) if opts[:username]
  
  opts[:headers] = {:params => opts.delete(:params)} if opts[:params]
  
  response = ::RestClient::Request.new(opts.merge(:method => :get)).execute
  response.to_str
end