Sha256: 5263bacb6bf29879699450f40eaaae51242d83d1d5accd11994465a897e7e868

Contents?: true

Size: 1.46 KB

Versions: 10

Compression:

Stored size: 1.46 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)
      [:start_date, :end_date].each do |param_name|
        options[param_name.to_s.gsub('_', '-')] = options.delete(param_name) if options[param_name]
      end

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
chartmogul-ruby-1.1.3 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.1.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.1.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.0.2 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.0.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.0.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-0.1.4 lib/chartmogul/metrics/base.rb
chartmogul-ruby-0.1.3 lib/chartmogul/metrics/base.rb
chartmogul-ruby-0.1.2 lib/chartmogul/metrics/base.rb
chartmogul-ruby-0.1.1 lib/chartmogul/metrics/base.rb