Sha256: f3fde2333a2f611cf54412f0c755be73d905aca2cc6934a3fe2b451b235bd304

Contents?: true

Size: 1.51 KB

Versions: 1

Compression:

Stored size: 1.51 KB

Contents

module ChartMogul
  module Metrics
    def self.all(options = {})
      ChartMogul::Metrics::AllKeyMetrics.all(preprocess_params(options))
    end

    def self.arpa(options = {})
      ChartMogul::Metrics::ARPAs.all(preprocess_params(options))
    end

    def self.arr(options = {})
      ChartMogul::Metrics::ARRs.all(preprocess_params(options))
    end

    def self.asp(options = {})
      ChartMogul::Metrics::ASPs.all(preprocess_params(options))
    end

    def self.customer_churn_rate(options = {})
      ChartMogul::Metrics::CustomerChurnRates.all(preprocess_params(options))
    end

    def self.customer_count(options = {})
      ChartMogul::Metrics::CustomerCounts.all(preprocess_params(options))
    end

    def self.mrr(options = {})
      ChartMogul::Metrics::MRRs.all(preprocess_params(options))
    end

    def self.ltv(options = {})
      ChartMogul::Metrics::LTVs.all(preprocess_params(options))
    end

    def self.mrr_churn_rate(options = {})
      ChartMogul::Metrics::MRRChurnRates.all(preprocess_params(options))
    end

    private

    def self.preprocess_params(options)
      %i[start_date end_date].each do |param_name|
        options[param_name.to_s.tr('_', '-')] = options.delete(param_name) if options[param_name]
      end

      %i[geo plans].each do |param_name|
        if options[param_name] && options[param_name].is_a?(Array)
          options[param_name] = options[param_name].join(',')
        end
      end
      options
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
chartmogul-ruby-1.1.5 lib/chartmogul/metrics/base.rb