palidanx-fb_graph 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore +21 -0
- data/LICENSE +20 -0
- data/README.rdoc +308 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/assets/fb_graph.ai +1726 -6
- data/assets/fb_graph.png +0 -0
- data/fb_graph.gemspec +327 -0
- data/lib/fb_graph.rb +75 -0
- data/lib/fb_graph/album.rb +133 -0
- data/lib/fb_graph/application.rb +57 -0
- data/lib/fb_graph/auth.rb +52 -0
- data/lib/fb_graph/auth/cookie.rb +43 -0
- data/lib/fb_graph/checkin.rb +44 -0
- data/lib/fb_graph/collection.rb +44 -0
- data/lib/fb_graph/comment.rb +20 -0
- data/lib/fb_graph/comparison.rb +9 -0
- data/lib/fb_graph/connection.rb +30 -0
- data/lib/fb_graph/connections.rb +3 -0
- data/lib/fb_graph/connections/accounts.rb +58 -0
- data/lib/fb_graph/connections/activities.rb +14 -0
- data/lib/fb_graph/connections/albums.rb +96 -0
- data/lib/fb_graph/connections/attending.rb +18 -0
- data/lib/fb_graph/connections/books.rb +14 -0
- data/lib/fb_graph/connections/checkins.rb +22 -0
- data/lib/fb_graph/connections/comments.rb +39 -0
- data/lib/fb_graph/connections/declined.rb +18 -0
- data/lib/fb_graph/connections/events.rb +21 -0
- data/lib/fb_graph/connections/feed.rb +90 -0
- data/lib/fb_graph/connections/friends.rb +14 -0
- data/lib/fb_graph/connections/groups.rb +14 -0
- data/lib/fb_graph/connections/home.rb +14 -0
- data/lib/fb_graph/connections/insights.rb +13 -0
- data/lib/fb_graph/connections/interests.rb +14 -0
- data/lib/fb_graph/connections/invited.rb +14 -0
- data/lib/fb_graph/connections/likes.rb +16 -0
- data/lib/fb_graph/connections/links.rb +21 -0
- data/lib/fb_graph/connections/maybe.rb +18 -0
- data/lib/fb_graph/connections/members.rb +14 -0
- data/lib/fb_graph/connections/movies.rb +14 -0
- data/lib/fb_graph/connections/music.rb +14 -0
- data/lib/fb_graph/connections/noreply.rb +14 -0
- data/lib/fb_graph/connections/notes.rb +21 -0
- data/lib/fb_graph/connections/photos.rb +21 -0
- data/lib/fb_graph/connections/picture.rb +14 -0
- data/lib/fb_graph/connections/posts.rb +14 -0
- data/lib/fb_graph/connections/statuses.rb +14 -0
- data/lib/fb_graph/connections/subscriptions.rb +53 -0
- data/lib/fb_graph/connections/tagged.rb +14 -0
- data/lib/fb_graph/connections/television.rb +14 -0
- data/lib/fb_graph/connections/videos.rb +14 -0
- data/lib/fb_graph/education.rb +25 -0
- data/lib/fb_graph/event.rb +47 -0
- data/lib/fb_graph/group.rb +27 -0
- data/lib/fb_graph/insight.rb +14 -0
- data/lib/fb_graph/link.rb +28 -0
- data/lib/fb_graph/node.rb +121 -0
- data/lib/fb_graph/note.rb +28 -0
- data/lib/fb_graph/page.rb +41 -0
- data/lib/fb_graph/photo.rb +41 -0
- data/lib/fb_graph/post.rb +50 -0
- data/lib/fb_graph/searchable.rb +25 -0
- data/lib/fb_graph/searchable/result.rb +31 -0
- data/lib/fb_graph/status.rb +23 -0
- data/lib/fb_graph/subscription.rb +14 -0
- data/lib/fb_graph/tag.rb +16 -0
- data/lib/fb_graph/user.rb +89 -0
- data/lib/fb_graph/venue.rb +17 -0
- data/lib/fb_graph/video.rb +28 -0
- data/lib/fb_graph/work.rb +35 -0
- data/spec/fake_json/albums/photos/matake_private.json +97 -0
- data/spec/fake_json/albums/photos/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/applications/subscriptions/fb_graph_private.json +12 -0
- data/spec/fake_json/checkins/search_private.json +54 -0
- data/spec/fake_json/checkins/search_public.json +6 -0
- data/spec/fake_json/events/attending/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/attending/smartday_private.json +44 -0
- data/spec/fake_json/events/declined/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/declined/smartday_private.json +720 -0
- data/spec/fake_json/events/invited/smartday_private.json +7092 -0
- data/spec/fake_json/events/maybe/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/events/maybe/smartday_private.json +956 -0
- data/spec/fake_json/events/noreply/smartday_private.json +896 -0
- data/spec/fake_json/groups/members/emacs_private.json +1996 -0
- data/spec/fake_json/pages/checkins/gowalla_private.json +113 -0
- data/spec/fake_json/pages/checkins/gowalla_public.json +6 -0
- data/spec/fake_json/pages/notes/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/pages/platform_private.json +13 -0
- data/spec/fake_json/pages/platform_public.json +13 -0
- data/spec/fake_json/pages/statuses/platform_private.json +258 -0
- data/spec/fake_json/pages/statuses/platform_public.json +6 -0
- data/spec/fake_json/posts/comments/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/posts/comments/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/posts/comments/post_without_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/posts/likes/post_without_access_token.json +1 -0
- data/spec/fake_json/posts/platform_private.json +97 -0
- data/spec/fake_json/posts/platform_public.json +52 -0
- data/spec/fake_json/users/accounts/matake_private.json +14 -0
- data/spec/fake_json/users/accounts/matake_private_with_manage_pages_permission.json +16 -0
- data/spec/fake_json/users/accounts/matake_public.json +6 -0
- data/spec/fake_json/users/activities/arjun_private.json +24 -0
- data/spec/fake_json/users/activities/arjun_public.json +6 -0
- data/spec/fake_json/users/albums/matake_private.json +36 -0
- data/spec/fake_json/users/albums/matake_public.json +6 -0
- data/spec/fake_json/users/albums/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/arjun_private.json +109 -0
- data/spec/fake_json/users/arjun_public.json +12 -0
- data/spec/fake_json/users/books/matake_private.json +9 -0
- data/spec/fake_json/users/books/matake_public.json +6 -0
- data/spec/fake_json/users/checkins/mattt_private.json +389 -0
- data/spec/fake_json/users/checkins/mattt_public.json +6 -0
- data/spec/fake_json/users/events/matake_private.json +71 -0
- data/spec/fake_json/users/events/matake_public.json +6 -0
- data/spec/fake_json/users/events/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/feed/arjun_private.json +520 -0
- data/spec/fake_json/users/feed/arjun_public.json +520 -0
- data/spec/fake_json/users/feed/post_with_invalid_access_token.json +1 -0
- data/spec/fake_json/users/feed/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/feed/post_without_access_token.json +1 -0
- data/spec/fake_json/users/friends/arjun_private.json +6 -0
- data/spec/fake_json/users/friends/arjun_public.json +6 -0
- data/spec/fake_json/users/friends/me_private.json +524 -0
- data/spec/fake_json/users/friends/me_public.json +6 -0
- data/spec/fake_json/users/groups/matake_private.json +48 -0
- data/spec/fake_json/users/groups/matake_public.json +6 -0
- data/spec/fake_json/users/home/arjun_private.json +6 -0
- data/spec/fake_json/users/home/arjun_public.json +6 -0
- data/spec/fake_json/users/home/me_private.json +460 -0
- data/spec/fake_json/users/home/me_private_next.json +382 -0
- data/spec/fake_json/users/home/me_private_previous.json +36 -0
- data/spec/fake_json/users/home/me_public.json +6 -0
- data/spec/fake_json/users/interests/matake_private.json +14 -0
- data/spec/fake_json/users/likes/arjun_private.json +1394 -0
- data/spec/fake_json/users/likes/arjun_public.json +6 -0
- data/spec/fake_json/users/links/matake_private.json +221 -0
- data/spec/fake_json/users/links/post_with_valid_access_token.json +1 -0
- data/spec/fake_json/users/me_private.json +128 -0
- data/spec/fake_json/users/me_public.json +6 -0
- data/spec/fake_json/users/movies/matake_private.json +9 -0
- data/spec/fake_json/users/music/matake_private.json +34 -0
- data/spec/fake_json/users/notes/matake_private.json +308 -0
- data/spec/fake_json/users/posts/arjun_private.json +386 -0
- data/spec/fake_json/users/posts/arjun_public.json +386 -0
- data/spec/fake_json/users/statuses/arjun_private.json +233 -0
- data/spec/fake_json/users/statuses/arjun_public.json +6 -0
- data/spec/fake_json/users/tagged/arjun_private.json +308 -0
- data/spec/fake_json/users/tagged/arjun_public.json +308 -0
- data/spec/fake_json/users/television/matake_private.json +9 -0
- data/spec/fake_json/users/videos/kirk_private.json +41 -0
- data/spec/fb_graph/album_spec.rb +61 -0
- data/spec/fb_graph/application_spec.rb +23 -0
- data/spec/fb_graph/auth_spec.rb +35 -0
- data/spec/fb_graph/checkin_spec.rb +29 -0
- data/spec/fb_graph/collection_spec.rb +45 -0
- data/spec/fb_graph/comment_spec.rb +31 -0
- data/spec/fb_graph/connection_spec.rb +38 -0
- data/spec/fb_graph/connections/accounts_spec.rb +47 -0
- data/spec/fb_graph/connections/activities_spec.rb +34 -0
- data/spec/fb_graph/connections/albums_spec.rb +60 -0
- data/spec/fb_graph/connections/attending_spec.rb +24 -0
- data/spec/fb_graph/connections/books_spec.rb +33 -0
- data/spec/fb_graph/connections/checkins_spec.rb +109 -0
- data/spec/fb_graph/connections/comments_spec.rb +85 -0
- data/spec/fb_graph/connections/declined_spec.rb +24 -0
- data/spec/fb_graph/connections/events_spec.rb +53 -0
- data/spec/fb_graph/connections/feed_spec.rb +102 -0
- data/spec/fb_graph/connections/friends_spec.rb +50 -0
- data/spec/fb_graph/connections/groups_spec.rb +32 -0
- data/spec/fb_graph/connections/home_spec.rb +58 -0
- data/spec/fb_graph/connections/interests_spec.rb +14 -0
- data/spec/fb_graph/connections/invited_spec.rb +14 -0
- data/spec/fb_graph/connections/likes_spec.rb +33 -0
- data/spec/fb_graph/connections/links_spec.rb +33 -0
- data/spec/fb_graph/connections/maybe_spec.rb +24 -0
- data/spec/fb_graph/connections/members_spec.rb +14 -0
- data/spec/fb_graph/connections/movies_spec.rb +14 -0
- data/spec/fb_graph/connections/music_spec.rb +14 -0
- data/spec/fb_graph/connections/noreply_spec.rb +14 -0
- data/spec/fb_graph/connections/notes_spec.rb +32 -0
- data/spec/fb_graph/connections/photos_spec.rb +30 -0
- data/spec/fb_graph/connections/picture_spec.rb +29 -0
- data/spec/fb_graph/connections/posts_spec.rb +35 -0
- data/spec/fb_graph/connections/statuses_spec.rb +74 -0
- data/spec/fb_graph/connections/subscriptions_spec.rb +18 -0
- data/spec/fb_graph/connections/tagged_spec.rb +42 -0
- data/spec/fb_graph/connections/television_spec.rb +14 -0
- data/spec/fb_graph/connections/videos_spec.rb +14 -0
- data/spec/fb_graph/education_spec.rb +61 -0
- data/spec/fb_graph/event_spec.rb +50 -0
- data/spec/fb_graph/group_spec.rb +46 -0
- data/spec/fb_graph/insight_spec.rb +17 -0
- data/spec/fb_graph/link_spec.rb +43 -0
- data/spec/fb_graph/node_spec.rb +13 -0
- data/spec/fb_graph/note_spec.rb +37 -0
- data/spec/fb_graph/page_spec.rb +56 -0
- data/spec/fb_graph/photo_spec.rb +60 -0
- data/spec/fb_graph/post_spec.rb +71 -0
- data/spec/fb_graph/status_spec.rb +31 -0
- data/spec/fb_graph/subscription_spec.rb +5 -0
- data/spec/fb_graph/tag_spec.rb +20 -0
- data/spec/fb_graph/user_spec.rb +139 -0
- data/spec/fb_graph/venue_spec.rb +23 -0
- data/spec/fb_graph/video_spec.rb +37 -0
- data/spec/fb_graph/work_spec.rb +67 -0
- data/spec/helpers/fake_json_helper.rb +11 -0
- data/spec/spec.opts +3 -0
- data/spec/spec_helper.rb +18 -0
- metadata +414 -0
@@ -0,0 +1,28 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Note < Node
|
3
|
+
include Connections::Comments
|
4
|
+
include Connections::Likes
|
5
|
+
|
6
|
+
attr_accessor :from, :subject, :message, :created_time, :updated_time, :icon
|
7
|
+
|
8
|
+
def initialize(identifier, attributes = {})
|
9
|
+
super
|
10
|
+
if (from = attributes[:from])
|
11
|
+
@from = if from[:category]
|
12
|
+
FbGraph::Page.new(from.delete(:id), from)
|
13
|
+
else
|
14
|
+
FbGraph::User.new(from.delete(:id), from)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@subject = attributes[:subject]
|
18
|
+
@message = attributes[:message]
|
19
|
+
if attributes[:created_time]
|
20
|
+
@created_time = Time.parse(attributes[:created_time]).utc
|
21
|
+
end
|
22
|
+
if attributes[:updated_time]
|
23
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
24
|
+
end
|
25
|
+
@icon = attributes[:icon]
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Page < Node
|
3
|
+
include Connections::Feed
|
4
|
+
include Connections::Picture
|
5
|
+
include Connections::Tagged
|
6
|
+
include Connections::Links
|
7
|
+
include Connections::Photos
|
8
|
+
include Connections::Groups
|
9
|
+
include Connections::Albums
|
10
|
+
include Connections::Statuses
|
11
|
+
include Connections::Videos
|
12
|
+
include Connections::Notes
|
13
|
+
include Connections::Posts
|
14
|
+
include Connections::Members
|
15
|
+
include Connections::Events
|
16
|
+
include Connections::Checkins
|
17
|
+
extend Searchable
|
18
|
+
|
19
|
+
attr_accessor :name, :username, :link, :category, :founded, :company_overview, :mission, :products, :fan_count, :location
|
20
|
+
|
21
|
+
def initialize(identifier, attributes = {})
|
22
|
+
super
|
23
|
+
@name = attributes[:name]
|
24
|
+
@username = attributes[:username]
|
25
|
+
@link = attributes[:link]
|
26
|
+
@category = attributes[:category]
|
27
|
+
if (founded = attributes[:founded])
|
28
|
+
@founded = Date.parse(founded) rescue Date.new(founded.to_i)
|
29
|
+
end
|
30
|
+
@company_overview = attributes[:company_overview]
|
31
|
+
@mission = attributes[:mission]
|
32
|
+
if (products = attributes[:products])
|
33
|
+
@products = products.split "\n"
|
34
|
+
end
|
35
|
+
@fan_count = attributes[:fan_count]
|
36
|
+
if (location = attributes[:location])
|
37
|
+
@venue = FbGraph::Venue.new(location)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Photo < Node
|
3
|
+
include Connections::Comments
|
4
|
+
include Connections::Likes
|
5
|
+
|
6
|
+
attr_accessor :from, :tags, :name, :picture, :icon, :source, :height, :width, :link, :created_time, :updated_time
|
7
|
+
|
8
|
+
def initialize(identifier, attributes = {})
|
9
|
+
super
|
10
|
+
if (from = attributes[:from])
|
11
|
+
@from = if from[:category]
|
12
|
+
FbGraph::Page.new(from.delete(:id), from)
|
13
|
+
else
|
14
|
+
FbGraph::User.new(from.delete(:id), from)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@tags = []
|
18
|
+
if attributes[:tags]
|
19
|
+
FbGraph::Collection.new(attributes[:tags]).each do |tag|
|
20
|
+
@tags << FbGraph::Tag.new(tag.delete(:id), tag)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
# NOTE:
|
24
|
+
# for some reason, facebook uses different parameter names.
|
25
|
+
# "name" in GET & "message" in POST
|
26
|
+
@name = attributes[:name] || attributes[:message]
|
27
|
+
@picture = attributes[:picture]
|
28
|
+
@icon = attributes[:icon]
|
29
|
+
@source = attributes[:source]
|
30
|
+
@height = attributes[:height]
|
31
|
+
@width = attributes[:width]
|
32
|
+
@link = attributes[:link]
|
33
|
+
if attributes[:created_time]
|
34
|
+
@created_time = Time.parse(attributes[:created_time]).utc
|
35
|
+
end
|
36
|
+
if attributes[:updated_time]
|
37
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Post < Node
|
3
|
+
include Connections::Comments
|
4
|
+
include Connections::Likes
|
5
|
+
extend Searchable
|
6
|
+
|
7
|
+
attr_accessor :from, :to, :message, :picture, :link, :name, :caption, :description, :source, :icon, :attribution, :actions, :likes, :created_time, :updated_time
|
8
|
+
|
9
|
+
def initialize(identifier, attributes = {})
|
10
|
+
super
|
11
|
+
if (from = attributes[:from])
|
12
|
+
@from = if from[:category]
|
13
|
+
FbGraph::Page.new(from.delete(:id), from)
|
14
|
+
else
|
15
|
+
FbGraph::User.new(from.delete(:id), from)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
@to = []
|
19
|
+
if attributes[:to]
|
20
|
+
FbGraph::Collection.new(attributes[:to]).each do |to|
|
21
|
+
@to << if to[:category]
|
22
|
+
FbGraph::Page.new(to.delete(:id), to)
|
23
|
+
else
|
24
|
+
FbGraph::User.new(to.delete(:id), to)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
@message = attributes[:message]
|
29
|
+
@picture = attributes[:picture]
|
30
|
+
@link = attributes[:link]
|
31
|
+
@name = attributes[:name]
|
32
|
+
@caption = attributes[:caption]
|
33
|
+
@description = attributes[:description]
|
34
|
+
@source = attributes[:source]
|
35
|
+
@icon = attributes[:icon]
|
36
|
+
@attribution = attributes[:attribution]
|
37
|
+
@actions = attributes[:actions]
|
38
|
+
@likes = attributes[:likes]
|
39
|
+
if attributes[:created_time]
|
40
|
+
@created_time = Time.parse(attributes[:created_time]).utc
|
41
|
+
end
|
42
|
+
if attributes[:updated_time]
|
43
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
44
|
+
end
|
45
|
+
|
46
|
+
# cached connection
|
47
|
+
@_comments_ = FbGraph::Collection.new(attributes[:comments])
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Searchable
|
3
|
+
def self.search(query, options = {})
|
4
|
+
klass = options.delete(:class) || FbGraph::Searchable
|
5
|
+
collection = FbGraph::Collection.new(
|
6
|
+
FbGraph::Node.new(:search).send(:get, options.merge(:q => query))
|
7
|
+
)
|
8
|
+
yield collection if block_given?
|
9
|
+
FbGraph::Searchable::Result.new(query, klass, options.merge(:collection => collection))
|
10
|
+
end
|
11
|
+
|
12
|
+
def search(query, options = {})
|
13
|
+
type = self.to_s.underscore.split('/').last
|
14
|
+
FbGraph::Searchable.search(query, options.merge(:type => type, :class => self)) do |collection|
|
15
|
+
collection.map! do |obj|
|
16
|
+
self.new(obj.delete(:id), obj.merge(
|
17
|
+
:access_token => options[:access_token]
|
18
|
+
))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
require 'fb_graph/searchable/result'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Searchable
|
3
|
+
class Result < Collection
|
4
|
+
attr_accessor :query, :klass, :collection, :options
|
5
|
+
|
6
|
+
def initialize(query, klass, options = {})
|
7
|
+
@klass = klass
|
8
|
+
@query = query
|
9
|
+
@options = options
|
10
|
+
@collection = options.delete(:collection) || FbGraph::Collection.new
|
11
|
+
replace @collection
|
12
|
+
end
|
13
|
+
|
14
|
+
def next(_options_ = {})
|
15
|
+
if self.collection.next.present?
|
16
|
+
self.klass.search(self.query, self.options.merge(_options_).merge(self.collection.next))
|
17
|
+
else
|
18
|
+
self.class.new(self.query, self.klass)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def previous(_options_ = {})
|
23
|
+
if self.collection.previous.present?
|
24
|
+
self.klassf.search(self.query, self.options.merge(_options_).merge(self.collection.previous))
|
25
|
+
else
|
26
|
+
self.class.new(self.query, self.klass)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Status < Node
|
3
|
+
include Connections::Comments
|
4
|
+
include Connections::Likes
|
5
|
+
|
6
|
+
attr_accessor :from, :message, :updated_time
|
7
|
+
|
8
|
+
def initialize(identifier, attributes = {})
|
9
|
+
super
|
10
|
+
if (from = attributes[:from])
|
11
|
+
@from = if from[:category]
|
12
|
+
FbGraph::Page.new(from.delete(:id), from)
|
13
|
+
else
|
14
|
+
FbGraph::User.new(from.delete(:id), from)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@message = attributes[:message]
|
18
|
+
if (updated_time = attributes.delete(:updated_time))
|
19
|
+
@updated_time = Time.parse(updated_time).utc
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Subscription
|
3
|
+
include FbGraph::Comparison
|
4
|
+
|
5
|
+
attr_accessor :object, :fields, :callback_url, :active
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
@object = attributes[:object]
|
9
|
+
@fields = attributes[:fields]
|
10
|
+
@callback_url = attributes[:callback_url]
|
11
|
+
@active = attributes[:active]
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/fb_graph/tag.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Tag
|
3
|
+
include Comparison
|
4
|
+
|
5
|
+
attr_accessor :user, :x, :y, :created_time
|
6
|
+
|
7
|
+
def initialize(identifier, attributes = {})
|
8
|
+
@x = attributes.delete(:x)
|
9
|
+
@y = attributes.delete(:y)
|
10
|
+
if (created_time = attributes.delete(:created_time))
|
11
|
+
@created_time = Time.parse(created_time).utc
|
12
|
+
end
|
13
|
+
@user = User.new(identifier, attributes)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class User < Node
|
3
|
+
include Connections::Home
|
4
|
+
include Connections::Feed
|
5
|
+
include Connections::Tagged
|
6
|
+
include Connections::Posts
|
7
|
+
include Connections::Picture
|
8
|
+
include Connections::Friends
|
9
|
+
include Connections::Activities
|
10
|
+
include Connections::Interests
|
11
|
+
include Connections::Music
|
12
|
+
include Connections::Books
|
13
|
+
include Connections::Movies
|
14
|
+
include Connections::Television
|
15
|
+
include Connections::Likes
|
16
|
+
include Connections::Photos
|
17
|
+
include Connections::Albums
|
18
|
+
include Connections::Videos
|
19
|
+
include Connections::Groups
|
20
|
+
include Connections::Statuses
|
21
|
+
include Connections::Links
|
22
|
+
include Connections::Notes
|
23
|
+
include Connections::Events
|
24
|
+
# --
|
25
|
+
# TODO
|
26
|
+
# include Connections::Inbox
|
27
|
+
# include Connections::Outbox
|
28
|
+
# include Connections::Updates
|
29
|
+
# ++
|
30
|
+
include Connections::Accounts
|
31
|
+
include Connections::Checkins
|
32
|
+
extend Searchable
|
33
|
+
|
34
|
+
attr_accessor :first_name, :last_name, :name, :link, :about, :birthday, :work, :education, :email, :website, :hometown, :location, :bio, :quotes, :gender, :interested_in, :meeting_for, :relationship_status, :religion, :political, :verified, :significant_other, :timezone, :updated_time
|
35
|
+
|
36
|
+
def initialize(identifier, attributes = {})
|
37
|
+
super
|
38
|
+
@first_name = attributes[:first_name]
|
39
|
+
@last_name = attributes[:last_name]
|
40
|
+
@name = attributes[:name]
|
41
|
+
@link = attributes[:link]
|
42
|
+
@about = attributes[:about]
|
43
|
+
if attributes[:birthday]
|
44
|
+
month, day, year = attributes[:birthday].split('/').collect(&:to_i)
|
45
|
+
year ||= 0
|
46
|
+
@birthday = Date.new(year, month, day)
|
47
|
+
end
|
48
|
+
@work = []
|
49
|
+
if attributes[:work]
|
50
|
+
attributes[:work].each do |work|
|
51
|
+
@work << FbGraph::Work.new(work)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
@education = []
|
55
|
+
if attributes[:education]
|
56
|
+
attributes[:education].each do |education|
|
57
|
+
@education << FbGraph::Education.new(education)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
@email = attributes[:email]
|
61
|
+
@website = attributes[:website].to_s.split("\n")
|
62
|
+
if (hometown = attributes[:hometown])
|
63
|
+
@hometown = FbGraph::Page.new(hometown.delete(:id), hometown)
|
64
|
+
end
|
65
|
+
if (location = attributes[:location])
|
66
|
+
@location = FbGraph::Page.new(location.delete(:id), location)
|
67
|
+
end
|
68
|
+
@bio = attributes[:bio]
|
69
|
+
@quotes = attributes[:quotes]
|
70
|
+
@gender = attributes[:gender]
|
71
|
+
@interested_in = Array(attributes[:interested_in])
|
72
|
+
@meeting_for = Array(attributes[:meeting_for])
|
73
|
+
@relationship_status = attributes[:relationship_status]
|
74
|
+
@religion = attributes[:religion]
|
75
|
+
@political = attributes[:political]
|
76
|
+
@verified = attributes[:verified]
|
77
|
+
@significant_other = attributes[:significant_other] # What's this??
|
78
|
+
@timezone = attributes[:timezone]
|
79
|
+
if attributes[:updated_time]
|
80
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def self.me(access_token)
|
85
|
+
new('me', :access_token => access_token)
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Venue
|
3
|
+
include Comparison
|
4
|
+
|
5
|
+
attr_accessor :street, :city, :state, :zip, :country, :latitude, :longitude
|
6
|
+
|
7
|
+
def initialize(attriutes = {})
|
8
|
+
@street = attriutes[:street]
|
9
|
+
@city = attriutes[:city]
|
10
|
+
@state = attriutes[:state]
|
11
|
+
@zip = attriutes[:zip]
|
12
|
+
@country = attriutes[:country]
|
13
|
+
@latitude = attriutes[:latitude]
|
14
|
+
@longitude = attriutes[:longitude]
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Video < Node
|
3
|
+
include Connections::Comments
|
4
|
+
include Connections::Likes
|
5
|
+
|
6
|
+
attr_accessor :from, :message, :description, :length, :created_time, :updated_time
|
7
|
+
|
8
|
+
def initialize(identifier, attributes = {})
|
9
|
+
super
|
10
|
+
if (from = attributes[:from])
|
11
|
+
@from = if from[:category]
|
12
|
+
FbGraph::Page.new(from.delete(:id), from)
|
13
|
+
else
|
14
|
+
FbGraph::User.new(from.delete(:id), from)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
@message = attributes[:message]
|
18
|
+
@description = attributes[:description]
|
19
|
+
@length = attributes[:length]
|
20
|
+
if attributes[:created_time]
|
21
|
+
@created_time = Time.parse(attributes[:created_time]).utc
|
22
|
+
end
|
23
|
+
if attributes[:updated_time]
|
24
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Work
|
3
|
+
include Comparison
|
4
|
+
|
5
|
+
attr_accessor :employer, :location, :position, :start_date, :end_date
|
6
|
+
|
7
|
+
def initialize(attributes = {})
|
8
|
+
if (employer = attributes[:employer])
|
9
|
+
@employer = FbGraph::Page.new(employer.delete(:id), employer)
|
10
|
+
end
|
11
|
+
if (location = attributes[:location])
|
12
|
+
@location = FbGraph::Page.new(location.delete(:id), location)
|
13
|
+
end
|
14
|
+
if (position = attributes[:position])
|
15
|
+
@position = FbGraph::Page.new(position.delete(:id), position)
|
16
|
+
end
|
17
|
+
if attributes[:start_date] && attributes[:start_date] != '0000-00'
|
18
|
+
year, month = attributes[:start_date].split('-').collect(&:to_i)
|
19
|
+
@start_date = if month == 0
|
20
|
+
Date.new(year)
|
21
|
+
else
|
22
|
+
Date.new(year, month)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
if attributes[:end_date] && attributes[:end_date] != '0000-00'
|
26
|
+
year, month = attributes[:end_date].split('-').collect(&:to_i)
|
27
|
+
@end_date = if month == 0
|
28
|
+
Date.new(year)
|
29
|
+
else
|
30
|
+
Date.new(year, month)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|