Class: FbGraph::Application

Constant Summary collapse

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

Instance Attribute Summary

Attributes inherited from Node

#access_token, #endpoint, #identifier

Instance Method Summary collapse

Methods included from OpenGraph::ApplicationContext

#og_action

Methods included from Connections::Videos

#video!, #videos

Methods included from Connections::TestUsers

#test_user!, #test_users

Methods included from Connections::Tagged

#tagged

Methods included from Connections::Subscriptions

#subscribe!, #subscriptions, #unsubscribe!

Methods included from Connections::Statuses

#statuses

Methods included from Connections::Reviews

#reviews

Methods included from Connections::Posts

#posts

Methods included from Connections::Picture

#picture

Methods included from Connections::Photos

#photo!, #photos

Methods included from Connections::Payments

#payments

Methods included from Connections::Notes

#note!, #notes

Methods included from Connections::Links

#link!, #links

Methods included from Connections::Insights

#insights

Methods included from Connections::Feed

#feed, #feed!

Methods included from Connections::Events

#event!, #events

Methods included from Connections::Albums

#album!, #albums

Methods included from Connections::Achievements

#achievement!, #achievements, #unregister_achievement!

Methods included from Connections::Accounts

#accounts

Methods inherited from Node

#connection, #destroy, fetch, #fetch, #update

Methods included from Comparison

#==

Constructor Details

#initialize(client_id, attributes = {}) ⇒ Application

Returns a new instance of Application.



42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fb_graph/application.rb', line 42

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

Instance Method Details

#access_token_with_auto_fetchObject



62
63
64
65
# File 'lib/fb_graph/application.rb', line 62

def access_token_with_auto_fetch
  access_token_without_auto_fetch ||
  self.secret && get_access_token
end

#get_access_token(secret = nil) ⇒ Object



56
57
58
59
60
# File 'lib/fb_graph/application.rb', line 56

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