Class: Vanity::Metric::GoogleAnalytics::Resource

Inherits:
Object
  • Object
show all
Defined in:
lib/vanity/metric/google_analytics.rb

Overview

Since:

  • 1.3.0

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(web_property_id, metric) ⇒ Resource

Returns a new instance of Resource.

Since:

  • 1.3.0



63
64
65
66
67
68
69
# File 'lib/vanity/metric/google_analytics.rb', line 63

def initialize(web_property_id, metric)
  self.class.send :include, Garb::Resource
  @web_property_id = web_property_id
  metrics metric
  dimensions :date
  sort :date
end

Instance Attribute Details

#profileObject (readonly)

GA profile used for this report. Populated after calling results.

Since:

  • 1.3.0



61
62
63
# File 'lib/vanity/metric/google_analytics.rb', line 61

def profile
  @profile
end

Instance Method Details

#results(start_date, end_date) ⇒ Object

Since:

  • 1.3.0



71
72
73
74
75
76
# File 'lib/vanity/metric/google_analytics.rb', line 71

def results(start_date, end_date)
  @profile = Garb::Profile.all.find { |p| p.web_property_id == @web_property_id }
  @start_date = start_date
  @end_date = end_date
  Garb::ReportResponse.new(send_request_for_body).results
end