Module: Google::Analytics::Admin

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

Constant Summary collapse

VERSION =
"0.5.1"

Class Method Summary collapse

Class Method Details

.analytics_admin_service(version: :v1alpha, transport: :grpc, &block) ⇒ ::Object

Create a new client object for AnalyticsAdminService.

By default, this returns an instance of Google::Analytics::Admin::V1alpha::AnalyticsAdminService::Client for a gRPC client for version V1alpha of the API. However, you can specify a different API version by passing it in the version parameter. If the AnalyticsAdminService service is supported by that API version, and the corresponding gem is available, the appropriate versioned client will be returned. You can also specify a different transport by passing :rest or :grpc in the transport parameter.

About AnalyticsAdminService

Service Interface for the Analytics Admin API (GA4).

Parameters:

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

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

  • transport (:grpc, :rest) (defaults to: :grpc)

    The transport to use. Defaults to :grpc.

Returns:

  • (::Object)

    A client object for the specified version.



52
53
54
55
56
57
58
59
60
61
62
# File 'lib/google/analytics/admin.rb', line 52

def self.analytics_admin_service version: :v1alpha, transport: :grpc, &block
  require "google/analytics/admin/#{version.to_s.downcase}"

  package_name = Google::Analytics::Admin
                 .constants
                 .select { |sym| sym.to_s.downcase == version.to_s.downcase.tr("_", "") }
                 .first
  service_module = Google::Analytics::Admin.const_get(package_name).const_get(:AnalyticsAdminService)
  service_module = service_module.const_get(:Rest) if transport == :rest
  service_module.const_get(:Client).new(&block)
end