Class: Garb::DataRequest
- Inherits:
-
Object
- Object
- Garb::DataRequest
- Defined in:
- lib/garb/data_request.rb
Instance Method Summary collapse
-
#initialize(base_url, parameters = {}) ⇒ DataRequest
constructor
A new instance of DataRequest.
- #query_string ⇒ Object
- #send_request ⇒ Object
- #uri ⇒ Object
Constructor Details
#initialize(base_url, parameters = {}) ⇒ DataRequest
Returns a new instance of DataRequest.
4 5 6 7 |
# File 'lib/garb/data_request.rb', line 4 def initialize(base_url, parameters={}) @base_url = base_url @parameters = parameters end |
Instance Method Details
#query_string ⇒ Object
9 10 11 12 |
# File 'lib/garb/data_request.rb', line 9 def query_string parameter_list = @parameters.map {|k,v| "#{k}=#{v}" } parameter_list.empty? ? '' : "?#{parameter_list.join('&')}" end |
#send_request ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/garb/data_request.rb', line 18 def send_request http = Net::HTTP.new(uri.host, uri.port) http.use_ssl = true http.verify_mode = OpenSSL::SSL::VERIFY_NONE response = http.get("#{uri.path}#{query_string}", 'Authorization' => "GoogleLogin auth=#{Session.auth_token}") raise response.body.inspect unless response.is_a?(Net::HTTPOK) response end |
#uri ⇒ Object
14 15 16 |
# File 'lib/garb/data_request.rb', line 14 def uri URI.parse(@base_url) end |