Sha256: 6b0a3b599ce95f1f7ceb8c558e2596ed4dbbe638d98cb0fadec6347b97e0dab6

Contents?: true

Size: 1.8 KB

Versions: 5

Compression:

Stored size: 1.8 KB

Contents

module Kanaui
  module DashboardHelper

    class DashboardApi < KillBillClient::Model::Resource

      KILLBILL_ANALYTICS_PREFIX = "/plugins/killbill-analytics"

      class << self

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

        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

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

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

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

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

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

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kanaui-2.0.0 app/helpers/kanaui/dashboard_helper.rb
kanaui-1.0.0 app/helpers/kanaui/dashboard_helper.rb
kanaui-0.6.1 app/helpers/kanaui/dashboard_helper.rb
kanaui-0.6.0 app/helpers/kanaui/dashboard_helper.rb
kanaui-0.5.1 app/helpers/kanaui/dashboard_helper.rb