Class: Legato::User

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

Constant Summary collapse

URL =
"https://www.googleapis.com/analytics/v3/data/ga"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, api_key = nil) ⇒ User

Returns a new instance of User.



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

def initialize(token, api_key = nil)
  self.access_token = token
  self.api_key = api_key
end

Instance Attribute Details

#access_tokenObject

Returns the value of attribute access_token.



3
4
5
# File 'lib/legato/user.rb', line 3

def access_token
  @access_token
end

#api_keyObject

Returns the value of attribute api_key.



3
4
5
# File 'lib/legato/user.rb', line 3

def api_key
  @api_key
end

Instance Method Details

#accountsObject

Management



27
28
29
# File 'lib/legato/user.rb', line 27

def accounts
  Management::Account.all(self)
end

#profilesObject



35
36
37
# File 'lib/legato/user.rb', line 35

def profiles
  Management::Profile.all(self)
end

#request(query) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/legato/user.rb', line 12

def request(query)
  raw_response = if api_key
    # oauth 1 + api key
    query_string = URI.escape(query.to_query_string, '<>') # may need to add !~@

    access_token.get(URL + query_string + "&key=#{api_key}")
  else
    # oauth 2
    access_token.get(URL, :params => query.to_params)
  end

  Response.new(raw_response, query.instance_klass)
end

#web_propertiesObject



31
32
33
# File 'lib/legato/user.rb', line 31

def web_properties
  Management::WebProperty.all(self)
end