Module: InstagramGraphApi::Client::Insights
- Included in:
- InstagramGraphApi::Client
- Defined in:
- lib/instagram_graph_api/client/insights.rb
Constant Summary collapse
- METRIC_HASH =
{ image: 'impressions,reach', video: 'impressions,reach,video_views', story: 'impressions,replies,reach,taps_forward,taps_back,exits' }
Instance Method Summary collapse
Instance Method Details
#insights(object_id, type: "image", metrics: nil) ⇒ Object
11 12 13 14 15 16 17 18 |
# File 'lib/instagram_graph_api/client/insights.rb', line 11 def insights(object_id, type: "image", metrics: nil) metrics ||= METRIC_HASH[type.to_sym] @raw_insights = get_connections(object_id, "insights?metric=#{metrics}") @raw_insights.reduce({}) do |result, insight_data| result[insight_data["name"]] = insight_data["values"].first["value"] result end end |