Class: Kanaui::DashboardHelper::DashboardApi
- Inherits:
-
KillBillClient::Model::Resource
- Object
- KillBillClient::Model::Resource
- Kanaui::DashboardHelper::DashboardApi
- Defined in:
- app/helpers/kanaui/dashboard_helper.rb
Constant Summary collapse
- KILLBILL_ANALYTICS_PREFIX =
'/plugins/killbill-analytics'
Class Method Summary collapse
- .available_reports(options = {}) ⇒ Object
- .create_report(report, options = {}) ⇒ Object
- .delete_report(name, options = {}) ⇒ Object
- .refresh(account_id, options = {}) ⇒ Object
- .refresh_report(name, options = {}) ⇒ Object
- .report_configuration(name, options = {}) ⇒ Object
- .reports(start_date, end_date, name, smooth, sql_only, format, options = {}) ⇒ Object
- .update_report(name, report, options = {}) ⇒ Object
Class Method Details
.available_reports(options = {}) ⇒ Object
14 15 16 17 18 |
# File 'app/helpers/kanaui/dashboard_helper.rb', line 14 def available_reports( = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports" response = KillBillClient::API.get path, {}, 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, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports" KillBillClient::API.post path, report, {}, end |
.delete_report(name, options = {}) ⇒ Object
55 56 57 58 |
# File 'app/helpers/kanaui/dashboard_helper.rb', line 55 def delete_report(name, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}" KillBillClient::API.delete path, {}, {}, end |
.refresh(account_id, options = {}) ⇒ Object
9 10 11 12 |
# File 'app/helpers/kanaui/dashboard_helper.rb', line 9 def refresh(account_id, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/#{account_id}" KillBillClient::API.put path, {}, {}, end |
.refresh_report(name, options = {}) ⇒ Object
45 46 47 48 |
# File 'app/helpers/kanaui/dashboard_helper.rb', line 45 def refresh_report(name, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}?shouldRefresh=true" KillBillClient::API.put path, {}, {}, end |
.report_configuration(name, options = {}) ⇒ Object
34 35 36 37 38 |
# File 'app/helpers/kanaui/dashboard_helper.rb', line 34 def report_configuration(name, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}" response = KillBillClient::API.get path, {}, 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, = {}) 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, {}, 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, = {}) path = "#{KILLBILL_ANALYTICS_PREFIX}/reports/#{name}" KillBillClient::API.put path, report, {}, end |