Module: Google::Analytics::Data

Defined in:
lib/google/analytics/data.rb,
lib/google/analytics/data/version.rb

Constant Summary collapse

VERSION =
"0.3.1"

Class Method Summary collapse

Class Method Details

.analytics_data(version: :v1beta, &block) ⇒ AnalyticsData::Client

Create a new client object for AnalyticsData.

By default, this returns an instance of Google::Analytics::Data::V1beta::AnalyticsData::Client for version V1beta of the API. However, you can specify specify a different API version by passing it in the version parameter. If the AnalyticsData service is supported by that API version, and the corresponding gem is available, the appropriate versioned client will be returned.

About AnalyticsData

Google Analytics reporting data service.

Parameters:

  • version (::String, ::Symbol) (defaults to: :v1beta)

    The API version to connect to. Optional. Defaults to :v1beta.

Returns:

  • (AnalyticsData::Client)

    A client object for the specified version.



49
50
51
52
53
54
55
56
57
58
# File 'lib/google/analytics/data.rb', line 49

def self.analytics_data version: :v1beta, &block
  require "google/analytics/data/#{version.to_s.downcase}"

  package_name = Google::Analytics::Data
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  package_module = Google::Analytics::Data.const_get package_name
  package_module.const_get(:AnalyticsData).const_get(:Client).new(&block)
end