Class: OmniSocials::Resources::Analytics
- Inherits:
-
Object
- Object
- OmniSocials::Resources::Analytics
- Defined in:
- lib/omnisocials/resources/analytics.rb
Overview
Analytics resource: post stats, account stats, overview, and best times.
Instance Method Summary collapse
-
#accounts(platform: nil, date: nil) ⇒ Object
GET /analytics/accounts - account-level stats (followers etc.).
-
#best_times(platform:, timezone: nil) ⇒ Object
GET /analytics/best-times - best times to post for a platform, derived from the workspace's own engagement history.
-
#initialize(client) ⇒ Analytics
constructor
A new instance of Analytics.
-
#overview(period: nil, start_date: nil, end_date: nil) ⇒ Object
GET /analytics/overview - workspace-wide analytics overview.
-
#post(post_id) ⇒ Object
GET /analytics/posts/id - latest per-platform metrics for one post.
-
#posts(ids) ⇒ Object
GET /analytics/posts?ids=a,b,c - bulk metrics for up to 100 posts in one request.
Constructor Details
#initialize(client) ⇒ Analytics
Returns a new instance of Analytics.
7 8 9 |
# File 'lib/omnisocials/resources/analytics.rb', line 7 def initialize(client) @client = client end |
Instance Method Details
#accounts(platform: nil, date: nil) ⇒ Object
GET /analytics/accounts - account-level stats (followers etc.).
35 36 37 38 39 40 |
# File 'lib/omnisocials/resources/analytics.rb', line 35 def accounts(platform: nil, date: nil) @client.request( "GET", "/analytics/accounts", query: { "platform" => platform, "date" => date } ) end |
#best_times(platform:, timezone: nil) ⇒ Object
GET /analytics/best-times - best times to post for a platform, derived from the workspace's own engagement history.
44 45 46 47 48 49 |
# File 'lib/omnisocials/resources/analytics.rb', line 44 def best_times(platform:, timezone: nil) @client.request( "GET", "/analytics/best-times", query: { "platform" => platform, "timezone" => timezone } ) end |
#overview(period: nil, start_date: nil, end_date: nil) ⇒ Object
GET /analytics/overview - workspace-wide analytics overview.
27 28 29 30 31 32 |
# File 'lib/omnisocials/resources/analytics.rb', line 27 def overview(period: nil, start_date: nil, end_date: nil) @client.request( "GET", "/analytics/overview", query: { "period" => period, "start_date" => start_date, "end_date" => end_date } ) end |
#post(post_id) ⇒ Object
GET /analytics/posts/id - latest per-platform metrics for one post.
12 13 14 |
# File 'lib/omnisocials/resources/analytics.rb', line 12 def post(post_id) @client.request("GET", "/analytics/posts/#{post_id}") end |
#posts(ids) ⇒ Object
GET /analytics/posts?ids=a,b,c - bulk metrics for up to 100 posts in
one request. ids is an Array of post ids (or an already-joined
comma-separated String).
19 20 21 22 23 24 |
# File 'lib/omnisocials/resources/analytics.rb', line 19 def posts(ids) @client.request( "GET", "/analytics/posts", query: { "ids" => Internal.join_list(ids) } ) end |