lib/grooveshark/request.rb in grooveshark-0.1.1 vs lib/grooveshark/request.rb in grooveshark-0.2.0
- old
+ new
@@ -10,11 +10,11 @@
METHOD_CLIENTS = {
'getStreamKeyFromSongIDEx' => 'jsqueue'
}
# Perform API request
- def request(method, params, secure=false)
+ def request(method, params={}, secure=false)
agent = METHOD_CLIENTS.key?(method) ? METHOD_CLIENTS[method] : CLIENT
url = "#{secure ? 'https' : 'http'}://#{API_BASE}/more.php?#{method}"
body = {
'header' => {
'session' => @session,
@@ -38,9 +38,10 @@
rescue Exception => ex
raise GeneralError # Need define error handling
end
data = JSON.parse(data)
+ data = data.normalize if data.kind_of?(Hash)
return data['result'] unless data['fault']
end
end
end
\ No newline at end of file