Sha256: 46d4f3604fafdfdc49a17dedac624c41c6ca957907afad1aba73b4e06641410a

Contents?: true

Size: 1.83 KB

Versions: 17

Compression:

Stored size: 1.83 KB

Contents

module FbGraph
  class Application < Node
    include Connections::Accounts
    include Connections::Achievements
    include Connections::Albums
    include Connections::Events
    include Connections::Feed
    include Connections::Insights
    include Connections::Links
    include Connections::Notes
    include Connections::Payments
    include Connections::Photos
    include Connections::Picture
    include Connections::Posts
    include Connections::Reviews
    include Connections::Statuses
    include Connections::Subscriptions
    include Connections::Tagged
    include Connections::TestUsers
    # TODO
    # include Connections::Translations
    include Connections::Videos
    include OpenGraph::ApplicationContext

    @@attributes = [
      :name,
      :namespace,
      :description,
      :category,
      :company,
      :icon_url,
      :subcategory,
      :link,
      :logo_url,
      :daily_active_users,
      :weekly_active_users,
      :monthly_active_users,
      :secret
    ]
    attr_accessor *@@attributes

    def initialize(client_id, attributes = {})
      super
      @@attributes.each do |key|
        # NOTE:
        # For some reason, Graph API returns daily_active_users, weekly_active_users, monthly_active_users as JSON string.
        value = if [:daily_active_users, :weekly_active_users, :monthly_active_users].include?(key)
          attributes[key].to_i
        else
          attributes[key]
        end
        self.send("#{key}=", value)
      end
    end

    def get_access_token(secret = nil)
      self.secret ||= secret
      auth = Auth.new(self.identifier, self.secret)
      self.access_token = auth.client.access_token!
    end

    def access_token_with_auto_fetch
      access_token_without_auto_fetch ||
      self.secret && get_access_token
    end
    alias_method_chain :access_token, :auto_fetch

  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
fb_graph-2.4.3 lib/fb_graph/application.rb
fb_graph-2.4.2 lib/fb_graph/application.rb
fb_graph-2.4.1 lib/fb_graph/application.rb
fb_graph-2.4.0 lib/fb_graph/application.rb
fb_graph-2.3.2 lib/fb_graph/application.rb
fb_graph-2.3.1 lib/fb_graph/application.rb
fb_graph-2.3.0 lib/fb_graph/application.rb
fb_graph-2.2.6 lib/fb_graph/application.rb
fb_graph-2.2.5 lib/fb_graph/application.rb
fb_graph-2.2.4 lib/fb_graph/application.rb
fb_graph-2.2.3 lib/fb_graph/application.rb
fb_graph-2.2.2 lib/fb_graph/application.rb
fb_graph-2.2.1 lib/fb_graph/application.rb
fb_graph-2.2.0 lib/fb_graph/application.rb
fb_graph-2.2.0.beta lib/fb_graph/application.rb
fb_graph-2.2.0.alpha2 lib/fb_graph/application.rb
fb_graph-2.2.0.alpha lib/fb_graph/application.rb