Sha256: 90619530525e98b3c401ef350726dc4be47f8711e90c3cb55d0e31a41f5bdffd

Contents?: true

Size: 1.09 KB

Versions: 2

Compression:

Stored size: 1.09 KB

Contents

module FbGraph
  module Connections
    module AdImages
      def ad_images(options = {})
        ad_images = self.connection :adimages, options
        ad_images.map! do |ad_image|
          AdImage.new ad_image[:id], ad_image.merge(
            :access_token => options[:access_token] || self.access_token
          )
        end
      end

      def ad_image!(options = {})
        ad_image = post options.merge(:connection => :adimages)

       # No ID is contained in the response.
        adimage_id = ad_image[:images].keys.first
        hash = ad_image[:images].values.first[:hash]
        url = ad_image[:images].values.first[:url]

        merged_attrs = options.merge(
          :access_token => options[:access_token] || self.access_token,
          :hash => hash,
          :url => url
        )

        if options[:redownload]
          merged_attrs = merged_attrs.merge(ad_image[:data][:adimages][adimage_id]).with_indifferent_access
        end
	
	# The first argument is the identifier, which is appended to the endpoint
        AdImage.new adimage_id, merged_attrs
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
fb_graph-2.7.17 lib/fb_graph/connections/ad_images.rb
fb_graph-2.7.16 lib/fb_graph/connections/ad_images.rb