Class: Kanaui::DashboardHelper::DashboardApi

Inherits:
KillBillClient::Model::Resource
  • Object
show all
Defined in:
app/helpers/kanaui/dashboard_helper.rb

Constant Summary collapse

KILLBILL_ANALYTICS_PREFIX =
"/plugins/killbill-analytics"

Class Method Summary collapse

Class Method Details

.available_reports(options = {}) ⇒ Object



10
11
12
13
14
# File 'app/helpers/kanaui/dashboard_helper.rb', line 10

def available_reports(options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports"
  response = KillBillClient::API.get path, {}, options
  response.body
end

.create_report(report, options = {}) ⇒ Object



30
31
32
33
# File 'app/helpers/kanaui/dashboard_helper.rb', line 30

def create_report(report, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports"
  KillBillClient::API.post path, report, {}, options
end

.delete_report(name, options = {}) ⇒ Object



45
46
47
48
# File 'app/helpers/kanaui/dashboard_helper.rb', line 45

def delete_report(name, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}"
  KillBillClient::API.delete path, {}, {}, options
end

.refresh_report(name, options = {}) ⇒ Object



35
36
37
38
# File 'app/helpers/kanaui/dashboard_helper.rb', line 35

def refresh_report(name, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}?shouldRefresh=true"
  KillBillClient::API.put path, {}, {}, options
end

.report_configuration(name, options = {}) ⇒ Object



24
25
26
27
28
# File 'app/helpers/kanaui/dashboard_helper.rb', line 24

def report_configuration(name, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}"
  response = KillBillClient::API.get path, {}, options
  JSON.parse(response.body).symbolize_keys
end

.reports(start_date, end_date, name, smooth, sql_only, format, options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'app/helpers/kanaui/dashboard_helper.rb', line 16

def reports(start_date, end_date, name, smooth, sql_only, format, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports?format=#{format}&startDate=#{start_date}&endDate=#{end_date}&name=#{name}"
  path = "#{path}&smooth=#{smooth}" if smooth
  path = "#{path}&sqlOnly=true" unless sql_only.blank?
  response = KillBillClient::API.get path, {}, options
  response.body
end

.update_report(name, report, options = {}) ⇒ Object



40
41
42
43
# File 'app/helpers/kanaui/dashboard_helper.rb', line 40

def update_report(name, report, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}"
  KillBillClient::API.put path, report, {}, options
end