lib/impas-client.rb in impas-client-0.0.5 vs lib/impas-client.rb in impas-client-0.0.6
- old
+ new
@@ -4,11 +4,11 @@
module Impas
class Client
attr_accessor :api_url, :op_key
- def initialize(args)
+ def initialize(args ={})
@api_url = (args[:api_url].nil?) ? API_URL : args[:api_url]
@op_key = args[:op_key]
@@conn = Faraday.new(:url => @api_url) do |faraday|
faraday.request :url_encoded
@@ -69,8 +69,20 @@
else
raise StandardError.new("HTTP status:#{res.status}")
end
true
+ end
+
+ def ranking(grp_key, type = "all", limit = 10)
+ entry_point = "/api/ranking/#{grp_key}/#{type}/#{limit}"
+ res = @@conn.get entry_point
+
+ if res.status != 200
+ raise StandardError.new("HTTP status:#{res.status}")
+ end
+
+ desc = JSON.parse(res.body)
+ desc["description"]["ranking"]
end
end
end