Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated uri to work with the new chartbeat v3 live api. #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions lib/chartbeat.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

class Chartbeat
YESTERDAY = Time.now.to_i - 86400
BASE_URI = 'chartbeat.com/api'
BASE_URI = 'api.chartbeat.com'
METHODS = [:pages, :pathsummary, :recent, :summize, :quickstats, :toppages, :histogram, :summary]
DASHAPI_METHODS = [:alerts, :snapshots, :stats, :data_series, :day_data_series]
DEFAULT_ARG_VALS = {:path => '/', :keys => 'n', :types => 'n', :since => YESTERDAY,
Expand All @@ -27,14 +27,14 @@ def method_missing(m, *args)

query = *args
query_to_perform = {:apikey => @apikey, :host => @host}
DEFAULT_ARG_VALS.each do |k,v|
if query && query[k]
v = query[k]
end
query_to_perform[k] = v
end
prefix = DASHAPI_METHODS.include?(m) ? '/dashapi' : ''
data = Crack::JSON.parse(RestClient.get("http://" + BASE_URI + prefix + '/' + m.to_s + '/', :params => query_to_perform))
# DEFAULT_ARG_VALS.each do |k,v|
# if query && query[k]
# v = query[k]
# end
# query_to_perform[k] = v
# end
prefix = DASHAPI_METHODS.include?(m) ? '/dashapi' : '/live'
data = Crack::JSON.parse(RestClient.get("http://" + BASE_URI + prefix + '/' + m.to_s + '/v3/', :params => query_to_perform))
end

end