Skip to content

Instantly share code, notes, and snippets.

@jerzyn
Created March 21, 2014 11:15
Show Gist options
  • Save jerzyn/9684047 to your computer and use it in GitHub Desktop.
Save jerzyn/9684047 to your computer and use it in GitHub Desktop.
Example Fetch Stats
def api_call_application_usage(domain, provider_key, application_id, metric, from, to, granularity)
url = "https://#{domain}/stats/applications/#{application_id}/usage.xml?provider_key=#{provider_key}&metric_name=#{metric}&since=#{from}&until=#{to}&granularity=#{granularity}"
response = RestClient.get url
raise Exception.new("Wrong response code (#{response.code}) in request #{url}") if response.code!=200
document = Nokogiri::XML(response.to_str)
return document.xpath("//usage/data/values").text.split(",")
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment