Module: FbGraph

Defined in:
lib/fb_graph.rb,
lib/fb_graph/tab.rb,
lib/fb_graph/doc.rb,
lib/fb_graph/tag.rb,
lib/fb_graph/auth.rb,
lib/fb_graph/page.rb,
lib/fb_graph/poke.rb,
lib/fb_graph/user.rb,
lib/fb_graph/work.rb,
lib/fb_graph/role.rb,
lib/fb_graph/link.rb,
lib/fb_graph/note.rb,
lib/fb_graph/node.rb,
lib/fb_graph/post.rb,
lib/fb_graph/klass.rb,
lib/fb_graph/venue.rb,
lib/fb_graph/event.rb,
lib/fb_graph/album.rb,
lib/fb_graph/video.rb,
lib/fb_graph/score.rb,
lib/fb_graph/place.rb,
lib/fb_graph/group.rb,
lib/fb_graph/image.rb,
lib/fb_graph/order.rb,
lib/fb_graph/photo.rb,
lib/fb_graph/offer.rb,
lib/fb_graph/cover.rb,
lib/fb_graph/query.rb,
lib/fb_graph/action.rb,
lib/fb_graph/review.rb,
lib/fb_graph/domain.rb,
lib/fb_graph/status.rb,
lib/fb_graph/device.rb,
lib/fb_graph/thread.rb,
lib/fb_graph/comment.rb,
lib/fb_graph/ad_user.rb,
lib/fb_graph/project.rb,
lib/fb_graph/checkin.rb,
lib/fb_graph/insight.rb,
lib/fb_graph/privacy.rb,
lib/fb_graph/message.rb,
lib/fb_graph/picture.rb,
lib/fb_graph/ad_group.rb,
lib/fb_graph/ad_image.rb,
lib/fb_graph/property.rb,
lib/fb_graph/location.rb,
lib/fb_graph/question.rb,
lib/fb_graph/test_user.rb,
lib/fb_graph/age_range.rb,
lib/fb_graph/targeting.rb,
lib/fb_graph/exception.rb,
lib/fb_graph/milestone.rb,
lib/fb_graph/education.rb,
lib/fb_graph/searchable.rb,
lib/fb_graph/comparison.rb,
lib/fb_graph/collection.rb,
lib/fb_graph/ad_account.rb,
lib/fb_graph/ad_keyword.rb,
lib/fb_graph/ad_preview.rb,
lib/fb_graph/connection.rb,
lib/fb_graph/application.rb,
lib/fb_graph/friend_list.rb,
lib/fb_graph/app_request.rb,
lib/fb_graph/ad_creative.rb,
lib/fb_graph/ad_campaign.rb,
lib/fb_graph/achievement.rb,
lib/fb_graph/auth/cookie.rb,
lib/fb_graph/notification.rb,
lib/fb_graph/subscription.rb,
lib/fb_graph/ad_group_stat.rb,
lib/fb_graph/serialization.rb,
lib/fb_graph/tagged_object.rb,
lib/fb_graph/reach_estimate.rb,
lib/fb_graph/friend_request.rb,
lib/fb_graph/promotable_post.rb,
lib/fb_graph/question_option.rb,
lib/fb_graph/connections/home.rb,
lib/fb_graph/ad_campaign_stat.rb,
lib/fb_graph/connections/feed.rb,
lib/fb_graph/connections/tabs.rb,
lib/fb_graph/connections/docs.rb,
lib/fb_graph/ad_keyword_valid.rb,
lib/fb_graph/user_achievement.rb,
lib/fb_graph/connections/tags.rb,
lib/fb_graph/open_graph/object.rb,
lib/fb_graph/connections/maybe.rb,
lib/fb_graph/connections/likes.rb,
lib/fb_graph/open_graph/action.rb,
lib/fb_graph/connections/votes.rb,
lib/fb_graph/connections/roles.rb,
lib/fb_graph/connections/music.rb,
lib/fb_graph/ad_campaign_group.rb,
lib/fb_graph/connections/pokes.rb,
lib/fb_graph/connections/posts.rb,
lib/fb_graph/connections/games.rb,
lib/fb_graph/connections/books.rb,
lib/fb_graph/connections/links.rb,
lib/fb_graph/connections/notes.rb,
lib/fb_graph/searchable/result.rb,
lib/fb_graph/connections/inbox.rb,
lib/fb_graph/connections/groups.rb,
lib/fb_graph/connections/scores.rb,
lib/fb_graph/connections/videos.rb,
lib/fb_graph/connections/family.rb,
lib/fb_graph/connections/movies.rb,
lib/fb_graph/connections/admins.rb,
lib/fb_graph/connections/albums.rb,
lib/fb_graph/connections/offers.rb,
lib/fb_graph/connections/tagged.rb,
lib/fb_graph/connections/outbox.rb,
lib/fb_graph/connections/events.rb,
lib/fb_graph/connections/photos.rb,
lib/fb_graph/connections/banned.rb,
lib/fb_graph/connections/picture.rb,
lib/fb_graph/connections/friends.rb,
lib/fb_graph/connections/noreply.rb,
lib/fb_graph/connections/senders.rb,
lib/fb_graph/connections/threads.rb,
lib/fb_graph/connections/members.rb,
lib/fb_graph/connections/blocked.rb,
lib/fb_graph/connections/reviews.rb,
lib/fb_graph/auth/signed_request.rb,
lib/fb_graph/connections/invited.rb,
lib/fb_graph/connections/declined.rb,
lib/fb_graph/connections/messages.rb,
lib/fb_graph/connections/checkins.rb,
lib/fb_graph/connections/accounts.rb,
lib/fb_graph/connections/payments.rb,
lib/fb_graph/connections/insights.rb,
lib/fb_graph/ad_connection_object.rb,
lib/fb_graph/connections/comments.rb,
lib/fb_graph/connections/statuses.rb,
lib/fb_graph/connections/settings.rb,
lib/fb_graph/connections/interests.rb,
lib/fb_graph/connections/questions.rb,
lib/fb_graph/ad_keyword_suggestion.rb,
lib/fb_graph/connections/ad_images.rb,
lib/fb_graph/connections/ad_groups.rb,
lib/fb_graph/connections/attending.rb,
lib/fb_graph/connections/test_users.rb,
lib/fb_graph/connections/television.rb,
lib/fb_graph/connections/activities.rb,
lib/fb_graph/connections/milestones.rb,
lib/fb_graph/connections/user_likes.rb,
lib/fb_graph/connections/subscribers.rb,
lib/fb_graph/connections/permissions.rb,
lib/fb_graph/connections/ad_previews.rb,
lib/fb_graph/connections/ad_accounts.rb,
lib/fb_graph/open_graph/user_context.rb,
lib/fb_graph/connections/achievements.rb,
lib/fb_graph/broad_targeting_category.rb,
lib/fb_graph/connections/ad_creatives.rb,
lib/fb_graph/connections/friend_lists.rb,
lib/fb_graph/connections/participants.rb,
lib/fb_graph/request_filters/debugger.rb,
lib/fb_graph/request_filters/scrubber.rb,
lib/fb_graph/connections/ad_campaigns.rb,
lib/fb_graph/page/category_attributes.rb,
lib/fb_graph/connections/app_requests.rb,
lib/fb_graph/connections/subscriptions.rb,
lib/fb_graph/connections/subscribed_to.rb,
lib/fb_graph/connections/notifications.rb,
lib/fb_graph/connections/conversations.rb,
lib/fb_graph/connections/ad_group_stats.rb,
lib/fb_graph/connections/ad_credit_line.rb,
lib/fb_graph/connections/mutual_friends.rb,
lib/fb_graph/connections/friend_requests.rb,
lib/fb_graph/connections/reach_estimates.rb,
lib/fb_graph/connections/question_options.rb,
lib/fb_graph/connections/promotable_posts.rb,
lib/fb_graph/connections/ad_campaign_stats.rb,
lib/fb_graph/connections/app_notifications.rb,
lib/fb_graph/connections/user_achievements.rb,
lib/fb_graph/open_graph/application_context.rb,
lib/fb_graph/connections/ad_campaign_groups.rb,
lib/fb_graph/connections/former_participants.rb,
lib/fb_graph/connections/ad_connection_objects.rb,
lib/fb_graph/connections/broad_targeting_categories.rb

Defined Under Namespace

Modules: Comparison, Connections, OpenGraph, RequestFilters, Searchable, Serialization Classes: Achievement, Action, AdAccount, AdCampaign, AdCampaignGroup, AdCampaignStat, AdConnectionObject, AdCreative, AdGroup, AdGroupStat, AdImage, AdKeyword, AdKeywordSuggestion, AdKeywordValid, AdPreview, AdUser, AdgroupFetchFailure, AgeRange, Album, AppRequest, Application, Auth, BadRequest, BroadTargetingCategory, Checkin, Collection, Comment, Connection, Cover, CreativeNotSaved, Device, Doc, Domain, Education, Event, Exception, FriendList, FriendRequest, Group, Image, Insight, InternalServerError, InvalidRequest, InvalidSession, InvalidToken, Klass, Link, Location, Message, Milestone, Node, NotFound, Note, Notification, Offer, OpenProcessFailure, Order, Page, Photo, Picture, Place, Poke, Post, Privacy, Project, PromotablePost, Property, Query, QueryConnection, QueryDuplicateKey, QueryError, QueryLockTimeout, Question, QuestionOption, ReachEstimate, Review, Role, Score, Status, Subscription, Tab, Tag, TaggedObject, Targeting, TargetingSpecNotSaved, TestUser, Thread, TransactionCommitFailure, Unauthorized, User, UserAchievement, Venue, Video, Work

Constant Summary

VERSION =
::File.read(
  ::File.join(::File.dirname(__FILE__), '../VERSION')
).delete("\n\r")
ROOT_URL =
'https://graph.facebook.com'
ERROR_HEADER_MATCHERS =
{
  /not_found/       => NotFound,
  /invalid_token/   => InvalidToken,
  /invalid_request/ => InvalidRequest
}
ERROR_EXCEPTION_MATCHERS =
{
  /Could\snot\ssave\screative/          => CreativeNotSaved,
  /QueryLockTimeoutException/           => QueryLockTimeout,
  /Could\snot\screate\stargeting\sspec/ => TargetingSpecNotSaved,
  /Could\snot\sfetch\sadgroups/         => AdgroupFetchFailure,
  /Failed\sto\sopen\sprocess/           => OpenProcessFailure,
  /Could\snot\scommit\stransaction/     => TransactionCommitFailure,
  /QueryErrorException/                 => QueryError,
  /QueryConnectionException/            => QueryConnection,
  /QueryDuplicateKeyException/          => QueryDuplicateKey
}

Class Method Summary collapse

Class Method Details

.debug(&block) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/fb_graph.rb', line 54

def self.debug(&block)
  rack_oauth2_original = Rack::OAuth2.debugging?
  original = self.debugging?
  debug!
  yield
ensure
  Rack::OAuth2.debugging = rack_oauth2_original
  self.debugging = original
end

.debug!Object



50
51
52
53
# File 'lib/fb_graph.rb', line 50

def self.debug!
  Rack::OAuth2.debug!
  self.debugging = true
end

.debugging=(boolean) ⇒ Object



46
47
48
49
# File 'lib/fb_graph.rb', line 46

def self.debugging=(boolean)
  Rack::OAuth2.debugging = boolean
  @@debugging = boolean
end

.debugging?Boolean



43
44
45
# File 'lib/fb_graph.rb', line 43

def self.debugging?
  @@debugging
end

.http_clientObject



65
66
67
68
69
70
71
72
73
# File 'lib/fb_graph.rb', line 65

def self.http_client
  _http_client_ = HTTPClient.new(
    :agent_name => "FbGraph (#{VERSION})"
  )
  _http_client_.request_filter << RequestFilters::Scrubber.new
  _http_client_.request_filter << RequestFilters::Debugger.new if debugging?
  http_config.try(:call, _http_client_)
  _http_client_
end

.http_config(&block) ⇒ Object



74
75
76
77
# File 'lib/fb_graph.rb', line 74

def self.http_config(&block)
  Rack::OAuth2.http_config &block unless Rack::OAuth2.http_config
  @@http_config ||= block
end

.loggerObject



34
35
36
# File 'lib/fb_graph.rb', line 34

def self.logger
  @@logger
end

.logger=(logger) ⇒ Object



37
38
39
# File 'lib/fb_graph.rb', line 37

def self.logger=(logger)
  @@logger = logger
end

.root_urlObject



26
27
28
29
30
31
32
# File 'lib/fb_graph.rb', line 26

def self.root_url
  if self.v2?
    File.join(ROOT_URL, 'v2.0')
  else
    ROOT_URL
  end
end

.v1!Object



14
15
16
# File 'lib/fb_graph.rb', line 14

def self.v1!
  @v2 = false
end

.v1?Boolean



20
21
22
# File 'lib/fb_graph.rb', line 20

def self.v1?
  !v2?
end

.v2!Object



17
18
19
# File 'lib/fb_graph.rb', line 17

def self.v2!
  @v2 = true
end

.v2?Boolean



23
24
25
# File 'lib/fb_graph.rb', line 23

def self.v2?
  !!@v2
end