Class: Hydrogen::Request
- Inherits:
-
Object
- Object
- Hydrogen::Request
- Includes:
- HTTParty
- Defined in:
- lib/hydrogen/request.rb
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Request
constructor
A new instance of Request.
- #perform_get(path, query = {}) ⇒ Object
- #perform_post(path, query = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Request
Returns a new instance of Request.
8 9 10 11 |
# File 'lib/hydrogen/request.rb', line 8 def initialize(={}) = {:mash => true}.merge() @auth = {:username => [:username], :password => [:password]} if [: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 |