Module: SocialMiner::Instagram::PostMapper

Defined in:
lib/social_miner/instagram/post_mapper.rb

Class Method Summary collapse

Class Method Details

.map(attrs) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/social_miner/instagram/post_mapper.rb', line 6

def map(attrs)
  published_at = Time.at(attrs["taken_at_timestamp"]) if attrs["taken_at_timestamp"]

  {
    social_id: attrs.fetch("id"),
    image_url: attrs.fetch("display_url"),
    shortcode: attrs.fetch("shortcode"),
    location_name: attrs.dig("location", "name"),
    description: description(attrs.dig("edge_media_to_caption", "edges")),
    published_at: published_at
  }
end