Class: Legato::User
- Inherits:
-
Object
- Object
- Legato::User
- Defined in:
- lib/legato/user.rb
Constant Summary collapse
- URL =
"https://www.googleapis.com/analytics/v3/data/ga"
Instance Attribute Summary collapse
-
#access_token ⇒ Object
Returns the value of attribute access_token.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
Instance Method Summary collapse
-
#accounts ⇒ Object
Management.
-
#initialize(token, api_key = nil) ⇒ User
constructor
A new instance of User.
- #profiles ⇒ Object
- #request(query) ⇒ Object
- #web_properties ⇒ Object
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_token ⇒ Object
Returns the value of attribute access_token.
3 4 5 |
# File 'lib/legato/user.rb', line 3 def access_token @access_token end |
#api_key ⇒ Object
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
#accounts ⇒ Object
Management
27 28 29 |
# File 'lib/legato/user.rb', line 27 def accounts Management::Account.all(self) end |
#profiles ⇒ Object
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_properties ⇒ Object
31 32 33 |
# File 'lib/legato/user.rb', line 31 def web_properties Management::WebProperty.all(self) end |