Class: GAShikomi::Subcommand::Ga
- Defined in:
- lib/ga_shikomi/subcommand/ga.rb
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#get(config) ⇒ Object
require –profile-id –begin-date –end-date –metrics.
Methods inherited from Base
Constructor Details
This class inherits a constructor from GAShikomi::Subcommand::Base
Instance Method Details
#get(config) ⇒ Object
require –profile-id –begin-date –end-date –metrics
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/ga_shikomi/subcommand/ga.rb', line 10 def get(config) opts = { 'ids' => ['profile_id'], 'start-date' => ['start_date'], 'end-date' => ['end_date'], 'metrics' => ['metrics'] } %w(ids metrics dimensions filters max-results output samplingLevel segment sort start-index fields).each {|e| opts[e] = config[e] if config[e] } if config result = api.execute(api.analytics.data.ga.get, opts) case result['rows'].size when 1 [result['totalsForAllResults']] else fields = %w(columnHeaders totalsForAllResults rows) fields.map {|e| {e => result[e]}}.reduce(:merge) end end |