Class: FathomAnalytics::Api
- Inherits:
-
Object
- Object
- FathomAnalytics::Api
- Defined in:
- lib/fathom_analytics/api.rb
Constant Summary collapse
- LIMIT =
50
Instance Attribute Summary collapse
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #add_site(name:) ⇒ Object
- #authenticate ⇒ Object
-
#initialize(url:, email:, password:) ⇒ Api
constructor
A new instance of Api.
- #page_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #page_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #referrer_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #referrer_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #remove_site(id:) ⇒ Object
- #site_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #site_realtime_stats(id:) ⇒ Object
- #site_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
- #sites ⇒ Object
Constructor Details
#initialize(url:, email:, password:) ⇒ Api
Returns a new instance of Api.
7 8 9 10 11 12 |
# File 'lib/fathom_analytics/api.rb', line 7 def initialize(url:, email:, password:) @url = url @email = email @password = password @auth_token = nil end |
Instance Attribute Details
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/fathom_analytics/api.rb', line 5 def email @email end |
#password ⇒ Object (readonly)
Returns the value of attribute password.
5 6 7 |
# File 'lib/fathom_analytics/api.rb', line 5 def password @password end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
5 6 7 |
# File 'lib/fathom_analytics/api.rb', line 5 def url @url end |
Instance Method Details
#add_site(name:) ⇒ Object
14 15 16 |
# File 'lib/fathom_analytics/api.rb', line 14 def add_site(name:) post_request(path: "/api/sites", params: { name: name }) end |
#authenticate ⇒ Object
60 61 62 63 64 65 66 67 68 69 |
# File 'lib/fathom_analytics/api.rb', line 60 def authenticate params = { "Email": email, "Password": password } response = post_request(path: "/api/session", params: params, authenticated: false) do |raw_response| set_auth_token(raw_response) end response end |
#page_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
45 46 47 48 |
# File 'lib/fathom_analytics/api.rb', line 45 def page_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/pages/agg/pageviews" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#page_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
40 41 42 43 |
# File 'lib/fathom_analytics/api.rb', line 40 def page_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/pages/agg" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#referrer_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
55 56 57 58 |
# File 'lib/fathom_analytics/api.rb', line 55 def referrer_agg_page_views_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/referrers/agg/pageviews" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#referrer_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
50 51 52 53 |
# File 'lib/fathom_analytics/api.rb', line 50 def referrer_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/referrers/agg" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#remove_site(id:) ⇒ Object
18 19 20 |
# File 'lib/fathom_analytics/api.rb', line 18 def remove_site(id:) delete_request(path: "/api/sites/#{id}") end |
#site_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
35 36 37 38 |
# File 'lib/fathom_analytics/api.rb', line 35 def site_agg_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/site/agg" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#site_realtime_stats(id:) ⇒ Object
26 27 28 |
# File 'lib/fathom_analytics/api.rb', line 26 def site_realtime_stats(id:) get_request(path: "/api/sites/#{id}/stats/site/realtime") end |
#site_stats(id:, from:, to:, limit: LIMIT, offset: 0) ⇒ Object
30 31 32 33 |
# File 'lib/fathom_analytics/api.rb', line 30 def site_stats(id:, from:, to:, limit: LIMIT, offset: 0) path = "/api/sites/#{id}/stats/site" get_request(path: path, before: to, after: from, limit: limit, offset: offset) end |
#sites ⇒ Object
22 23 24 |
# File 'lib/fathom_analytics/api.rb', line 22 def sites get_request(path: "/api/sites") end |