Class: Zvent::Base
Instance Method Summary collapse
-
#get_resources(url) ⇒ Object
Get Json and parse it.
Instance Method Details
#get_resources(url) ⇒ Object
Get Json and parse it
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zvent/base.rb', line 21 def get_resources(url) url = URI.parse(url) res = Net::HTTP.start(url.host, url.port) {|http| http.get(url.request_uri+"&format=json&key=#{@api_key}") } resources = JSON.parse(res.body) if resources['rsp']['status'] == 'error' raise Zvent::ZventApiError.new(resources['rsp']['msg']) end return resources end |