Sha256: 8c5390933f9d4b7c09f2044e2ebdbda20112648ff29613833ce1f9034c8bdf28

Contents?: true

Size: 2 KB

Versions: 8

Compression:

Stored size: 2 KB

Contents

# frozen_string_literal: true

module Kanaui
  module DashboardHelper
    class DashboardApi < KillBillClient::Model::Resource
      KILLBILL_ANALYTICS_PREFIX = '/plugins/killbill-analytics'

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

        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

8 entries across 8 versions & 1 rubygems

Version Path
kanaui-4.0.2 app/helpers/kanaui/dashboard_helper.rb
kanaui-4.0.1 app/helpers/kanaui/dashboard_helper.rb
kanaui-2.2.1 app/helpers/kanaui/dashboard_helper.rb
kanaui-4.0.0 app/helpers/kanaui/dashboard_helper.rb
kanaui-2.1.3 app/helpers/kanaui/dashboard_helper.rb
kanaui-2.1.2 app/helpers/kanaui/dashboard_helper.rb
kanaui-2.1.1 app/helpers/kanaui/dashboard_helper.rb
kanaui-2.1.0 app/helpers/kanaui/dashboard_helper.rb