module Goodreads::Handler
Public Instance Methods
build_uri(params)
click to toggle source
# File lib/goodreads/api/handler.rb, line 17 def build_uri(params) URI::HTTPS.build(host: params[:base_url], path: params[:path], query: URI.encode_www_form(params[:data])) end
call(uri)
click to toggle source
# File lib/goodreads/api/handler.rb, line 3 def call(uri) uri = URI.encode(uri.to_s) url = URI.parse(uri) http = Net::HTTP.new(url.host, url.port) http.use_ssl = true x = http.get(url) if (x.body[0] == '<') parse_xml(x) else parse_json(x) end return x end
parse_json(response)
click to toggle source
# File lib/goodreads/api/handler.rb, line 27 def parse_json(response) res = JSON.parse(response.body) puts res end
parse_xml(response)
click to toggle source
# File lib/goodreads/api/handler.rb, line 22 def parse_xml(response) res = Hash.from_xml(response.body) puts res end