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



14
15
16
17
18
# File 'app/helpers/kanaui/dashboard_helper.rb', line 14

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

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



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

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

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



49
50
51
52
# File 'app/helpers/kanaui/dashboard_helper.rb', line 49

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

.refresh(account_id, options = {}) ⇒ Object



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

def refresh(, options = {})
  path = "#{KILLBILL_ANALYTICS_PREFIX}/#{account_id}"
  KillBillClient::API.put path, {}, {}, options
end

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



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

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

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



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

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



20
21
22
23
24
25
26
# File 'app/helpers/kanaui/dashboard_helper.rb', line 20

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



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

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