Module: GoGoodreads::Request
- Included in:
- Book
- Defined in:
- lib/go_goodreads/request.rb
Constant Summary collapse
- BASE_URL =
"http://www.goodreads.com"
Instance Method Summary collapse
-
#request(path, params = {}) {|xml| ... } ⇒ Object
Does the HTTP request and converting to Nokogiri::XML.
Instance Method Details
#request(path, params = {}) {|xml| ... } ⇒ Object
Does the HTTP request and converting to Nokogiri::XML.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/go_goodreads/request.rb', line 14 def request(path, params = {}, &block) params.merge!(:key => GoGoodreads::Config.api_key) begin r = ::RestClient.get(BASE_URL + path, :params => params) yield Nokogiri::XML(r.to_str) rescue ::RestClient::Exception => ex if ex.http_code == 401 raise BadApiKey else raise end end end |