Sha256: f6e84f785fb0ec6bb94a57e534be55dca55309eacb1bc447bfb5b85b0ef7a274

Contents?: true

Size: 739 Bytes

Versions: 1

Compression:

Stored size: 739 Bytes

Contents

module FbGraph
  module Connections
    module Insights
      def insights(options = {})
        options[:access_token] ||= self.access_token
        options[:access_token] ||= get_access_token(options[:secret]) if respond_to?(:get_access_token)
        insights = self.connection(:insights, options.merge(:connection_scope => connection_scope(options)))
        insights.map! do |insight|
          Insight.new(insight.delete(:id), insight.merge(:access_token => options[:access_token]))
        end
      end

      private

      def connection_scope(options)
        if metrics = options.delete(:metrics)
          File.join([metrics, options.delete(:period)].compact)
        else
          nil
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_graph-1.1.2 lib/fb_graph/connections/insights.rb