Class: FbGraph::Application

Constant Summary collapse

@@attributes =
[
  :name,
  :namespace,
  :description,
  :canvas_name,
  :category,
  :subcategory,
  :link,
  :company,
  :icon_url,
  :logo_url,
  :daily_active_users,
  :weekly_active_users,
  :monthly_active_users,
  :migrations,
  :namespace,
  :restrictions,
  :app_domains,
  :auth_dialog_data_help_url,
  :auth_dialog_description,
  :auth_dialog_headline,
  :auth_dialog_perms_explanation,
  :auth_referral_user_perms,
  :auth_referral_friend_perms,
  :auth_referral_default_activity_privacy,
  :auth_referral_enabled,
  :auth_referral_extended_perms,
  :auth_referral_response_type,
  :canvas_fluid_height,
  :canvas_fluid_width,
  :canvas_url,
  :contact_email,
  :created_time,
  :creator_uid,
  :deauth_callback_url,
  :iphone_app_store_id,
  :hosting_url,
  :mobile_web_url,
  :page_tab_default_name,
  :page_tab_url,
  :privacy_policy_url,
  :secure_canvas_url,
  :secure_page_tab_url,
  :server_ip_whitelist,
  :social_discovery,
  :terms_of_service_url,
  :user_support_email,
  :user_support_url,
  :website_url,
  :type,
  :secret
]

Instance Attribute Summary

Attributes inherited from Node

#access_token, #endpoint, #identifier, #raw_attributes

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.



79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/fb_graph/application.rb', line 79

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
    # Boolean fields may be returned as 1 for true or 0 for false
    elsif [:auth_referral_enabled, :canvas_fluid_height, :canvas_fluid_width, :social_discovery]
      if attributes[key] == 1
        true
      elsif attributes[key] == 0
        false
      else
        attributes[key]
      end
    else
      attributes[key]
    end
    self.send("#{key}=", value)
  end
end

Instance Method Details

#access_token_with_auto_fetchObject



108
109
110
111
# File 'lib/fb_graph/application.rb', line 108

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

#get_access_token(secret = nil) ⇒ Object



102
103
104
105
106
# File 'lib/fb_graph/application.rb', line 102

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