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



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

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

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



55
56
57
58
# File 'app/helpers/kanaui/dashboard_helper.rb', line 55

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}/#{}"
  KillBillClient::API.put path, {}, {}, options
end

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



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

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

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



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

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
27
28
29
30
31
32
# File 'app/helpers/kanaui/dashboard_helper.rb', line 20

def reports(start_date, end_date, name, smooth, sql_only, format, options = {})
  query = {
    'format' => format,
    'startDate' => start_date,
    'endDate' => end_date,
    'name' => name
  }
  query['smooth'] = smooth if smooth
  query['sqlOnly'] = 'true' if sql_only.present?
  path = "#{KILLBILL_ANALYTICS_PREFIX}/reports?#{query.to_query}"
  response = KillBillClient::API.get path, {}, options
  response.body
end

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



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

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