Module: InstagramGraphApi::Client::Media

Included in:
InstagramGraphApi::Client
Defined in:
lib/instagram_graph_api/client/media.rb

Constant Summary collapse

MEDIA_INFO_HASH =
{
  image: "comments_count,like_count,media_type,"\
              "media_url,permalink,timestamp,thumbnail_url",
  video: "comments_count,like_count,media_type,"\
              "media_url,permalink,timestamp,thumbnail_url",
  story: "media_type,media_url,permalink,"\
                "timestamp,thumbnail_url"
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#media_infoObject

Returns the value of attribute media_info.



4
5
6
# File 'lib/instagram_graph_api/client/media.rb', line 4

def media_info
  @media_info
end

#raw_insightsObject

Returns the value of attribute raw_insights.



4
5
6
# File 'lib/instagram_graph_api/client/media.rb', line 4

def raw_insights
  @raw_insights
end

Instance Method Details

#get_media_details(media_id, fields = nil, type: "image") ⇒ Object



24
25
26
27
# File 'lib/instagram_graph_api/client/media.rb', line 24

def get_media_details(media_id, fields = nil, type: "image")
  fields ||= MEDIA_INFO_HASH[type.to_sym]
  get_connections(media_id , "?fields=#{fields}")
end

#get_user_recent_media(id, fields = nil, type: "image", options: {}) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/instagram_graph_api/client/media.rb', line 15

def get_user_recent_media(id, fields = nil, type: "image", options: {})
  entity = type.eql?("story") ? "stories" : "media"
  fields ||= MEDIA_INFO_HASH[type.to_sym]
  query = "#{entity}?fields=#{fields}"
  query += "&after=#{options[:after]}" if options[:after]
  query += "&before=#{options[:before]}" if options[:before]
  get_connections(id, query)
end