Sha256: 20751cf5a80e99659451511825b9ac05852f22d0c699caa37a05656f258a06c3
Contents?: true
Size: 891 Bytes
Versions: 1
Compression:
Stored size: 891 Bytes
Contents
# frozen_string_literal: true require 'json' require 'date' module GoogleAnalyticsV4Api class Report attr_accessor :date_ranges, :dimensions, :metrics, :dimension_filter def initialize(start_date: nil, end_date: nil, dimensions: [], metrics: [], dimension_filter: {}) @date_ranges = [{ "startDate": start_date || (Date.today - 30), "endDate": end_date || Date.today }] @dimensions = dimensions.map { |dimension| { "name": dimension } } @metrics = metrics.map { |metric| { "name": metric } } @dimension_filter = dimension_filter end def to_json output = {} output[:dateRanges] = @date_ranges if @date_ranges output[:dimensions] = @dimensions if @dimensions.any? output[:metrics] = @metrics if @metrics.any? output[:dimensionFilter] = @dimension_filter if @dimension_filter.any? output.to_json end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
google_analytics_v4_api-0.0.4 | lib/google_analytics_v4_api/report.rb |