Class: GoogleAnalytics::User

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

Instance Method Summary collapse

Constructor Details

#initialize(username, password) ⇒ User

Returns a new instance of User.



5
6
7
# File 'lib/google_analytics/user.rb', line 5

def initialize(username, password)
  @client = Client.new username, password
end

Instance Method Details

#account(id) ⇒ Object



17
18
19
20
21
# File 'lib/google_analytics/user.rb', line 17

def (id)
  accounts.find do ||
     if .id == id
  end
end

#accountsObject



9
10
11
12
13
14
15
# File 'lib/google_analytics/user.rb', line 9

def accounts
  return @accounts if @accounts
  xml = @client.get('/feeds/accounts/default')
  @accounts = xml.xpath('//xmlns:entry').collect do ||
    Account.from_node(@client, )
  end
end

#valid?Boolean

Returns:

  • (Boolean)


23
24
25
26
27
28
# File 'lib/google_analytics/user.rb', line 23

def valid?
  @client.login!
  true
rescue NotAuthorized
  false
end