Class: LazyGoogleAnalytics::Auth

Inherits:
Object
  • Object
show all
Defined in:
lib/lazy_google_analytics/auth.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAuth

Returns a new instance of Auth.



6
7
8
9
10
# File 'lib/lazy_google_analytics/auth.rb', line 6

def initialize
  config = LazyGoogleAnalytics::Config
  @key = Google::APIClient::PKCS12.load_key(config.key_file, config.pass_phrase)
  @asserter = Google::APIClient::JWTAsserter.new( config.email, config.scope, @key)
end

Instance Attribute Details

#analyticsObject

Returns the value of attribute analytics.



4
5
6
# File 'lib/lazy_google_analytics/auth.rb', line 4

def analytics
  @analytics
end

#clientObject

Returns the value of attribute client.



4
5
6
# File 'lib/lazy_google_analytics/auth.rb', line 4

def client
  @client
end

Instance Method Details

#authorizeObject



12
13
14
15
16
# File 'lib/lazy_google_analytics/auth.rb', line 12

def authorize
  @client = Google::APIClient.new()
  @client.authorization = @asserter.authorize()
  @analytics = @client.discovered_api("analytics",'v3')
end