Class: Hydrogen::Request

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hydrogen/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Request

Returns a new instance of Request.



8
9
10
11
# File 'lib/hydrogen/request.rb', line 8

def initialize(options={})
  @options = {:mash => true}.merge(options)
  @auth = {:username => @options[:username], :password => @options[:password]} if @options[:username]
end

Instance Method Details

#perform_get(path, query = {}) ⇒ Object



14
15
16
17
# File 'lib/hydrogen/request.rb', line 14

def perform_get(path, query={})
  response = self.class.get("#{@options[:base_uri]}#{path}", { :query => query, :basic_auth => @auth })
  perform(response)
end

#perform_post(path, query = {}) ⇒ Object



20
21
22
23
# File 'lib/hydrogen/request.rb', line 20

def perform_post(path, query={})
  response = self.class.post("#{@options[:base_uri]}#{path}", { :query => query, :basic_auth => @auth })
  perform(response)
end