Sha256: 61552f0a7307a7a5d418a69802cd08a7dd2b7d5efbf5d17deadcbb2398a04147

Contents?: true

Size: 1.46 KB

Versions: 14

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)
      %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

14 entries across 14 versions & 1 rubygems

Version Path
chartmogul-ruby-1.5.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.5.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.4.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.4.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.3.3 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.3.2 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.3.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.3.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.2.2 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.2.1 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.2.0 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.1.9 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.1.8 lib/chartmogul/metrics/base.rb
chartmogul-ruby-1.1.7 lib/chartmogul/metrics/base.rb