fb_graph 1.8.6 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +1 -1
- data/VERSION +1 -1
- data/lib/fb_graph/album.rb +5 -4
- data/lib/fb_graph/application.rb +2 -0
- data/lib/fb_graph/auth/cookie.rb +4 -3
- data/lib/fb_graph/connections/accounts.rb +6 -1
- data/lib/fb_graph/connections/docs.rb +14 -0
- data/lib/fb_graph/connections/inbox.rb +5 -2
- data/lib/fb_graph/connections/outbox.rb +17 -0
- data/lib/fb_graph/connections/reviews.rb +14 -0
- data/lib/fb_graph/connections/threads.rb +14 -0
- data/lib/fb_graph/doc.rb +18 -0
- data/lib/fb_graph/domain.rb +32 -0
- data/lib/fb_graph/group.rb +3 -4
- data/lib/fb_graph/insight.rb +0 -2
- data/lib/fb_graph/link.rb +1 -2
- data/lib/fb_graph/message.rb +1 -8
- data/lib/fb_graph/node.rb +3 -3
- data/lib/fb_graph/post.rb +14 -5
- data/lib/fb_graph/property.rb +13 -0
- data/lib/fb_graph/review.rb +20 -0
- data/lib/fb_graph/thread.rb +1 -2
- data/lib/fb_graph/user.rb +53 -44
- data/lib/fb_graph/video.rb +12 -3
- data/lib/fb_graph.rb +4 -0
- data/spec/fb_graph/album_spec.rb +2 -0
- data/spec/fb_graph/auth/cookie_spec.rb +18 -7
- data/spec/fb_graph/connections/accounts_spec.rb +13 -0
- data/spec/fb_graph/connections/docs_spec.rb +14 -0
- data/spec/fb_graph/connections/home_spec.rb +0 -1
- data/spec/fb_graph/connections/inbox_spec.rb +6 -3
- data/spec/fb_graph/connections/insights_spec.rb +2 -2
- data/spec/fb_graph/connections/likes_spec.rb +2 -2
- data/spec/fb_graph/connections/outbox_spec.rb +15 -0
- data/spec/fb_graph/connections/reviews_spec.rb +14 -0
- data/spec/fb_graph/connections/threads_spec.rb +12 -0
- data/spec/fb_graph/doc_spec.rb +27 -0
- data/spec/fb_graph/domain_spec.rb +23 -0
- data/spec/fb_graph/group_spec.rb +0 -18
- data/spec/fb_graph/link_spec.rb +0 -2
- data/spec/fb_graph/message_spec.rb +0 -2
- data/spec/fb_graph/node_spec.rb +2 -2
- data/spec/fb_graph/post_spec.rb +24 -2
- data/spec/fb_graph/user_spec.rb +0 -3
- data/spec/fb_graph/video_spec.rb +14 -20
- data/spec/helpers/webmock_helper.rb +1 -1
- data/spec/mock_json/applications/accounts/private.json +9 -0
- data/spec/mock_json/applications/reviews/public.json +354 -0
- data/spec/mock_json/domains/search_public.json +10 -0
- data/spec/mock_json/groups/docs/private.json +31 -0
- data/spec/mock_json/posts/no_comments.json +1 -2
- data/spec/mock_json/users/feed/arjun_private.json +0 -3
- data/spec/mock_json/users/feed/arjun_public.json +0 -3
- data/spec/mock_json/users/home/me_private.json +0 -22
- data/spec/mock_json/users/home/me_private_next.json +0 -24
- data/spec/mock_json/users/home/me_private_previous.json +0 -1
- data/spec/mock_json/users/inbox/me_private.json +43 -78
- data/spec/mock_json/users/outbox/me_private.json +51 -0
- data/spec/mock_json/users/posts/arjun_private.json +0 -4
- data/spec/mock_json/users/posts/arjun_public.json +0 -4
- data/spec/mock_json/users/tagged/arjun_private.json +0 -1
- data/spec/mock_json/users/tagged/arjun_public.json +0 -1
- data/spec/mock_json/users/threads/me_private.json +91 -0
- data/spec/mock_json/videos/private.json +78 -0
- metadata +74 -2
data/Gemfile.lock
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.
|
1
|
+
1.9.0
|
data/lib/fb_graph/album.rb
CHANGED
@@ -5,7 +5,7 @@ module FbGraph
|
|
5
5
|
include Connections::Likes
|
6
6
|
include Connections::Picture
|
7
7
|
|
8
|
-
attr_accessor :from, :name, :description, :location, :link, :privacy, :count, :
|
8
|
+
attr_accessor :from, :name, :description, :location, :link, :cover_photo, :privacy, :count, :type, :created_time, :updated_time
|
9
9
|
|
10
10
|
def initialize(identifier, attributes = {})
|
11
11
|
super
|
@@ -20,15 +20,16 @@ module FbGraph
|
|
20
20
|
# NOTE:
|
21
21
|
# for some reason, facebook uses different parameter names.
|
22
22
|
# "description" in GET & "message" in POST
|
23
|
-
# TODO:
|
24
|
-
# check whether this issue is solved or not
|
25
23
|
@description = attributes[:description] || attributes[:message]
|
26
24
|
@location = attributes[:location]
|
27
25
|
@link = attributes[:link]
|
28
26
|
@privacy = attributes[:privacy]
|
29
27
|
@count = attributes[:count]
|
30
28
|
@type = attributes[:type]
|
31
|
-
|
29
|
+
|
30
|
+
@cover_photo = if attributes[:cover_photo]
|
31
|
+
Photo.new(attributes[:cover_photo])
|
32
|
+
end
|
32
33
|
@created_time = if attributes[:created_time]
|
33
34
|
Time.parse(attributes[:created_time]).utc
|
34
35
|
end
|
data/lib/fb_graph/application.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Application < Node
|
3
|
+
include Connections::Accounts
|
3
4
|
include Connections::Albums
|
4
5
|
include Connections::Events
|
5
6
|
include Connections::Feed
|
@@ -10,6 +11,7 @@ module FbGraph
|
|
10
11
|
include Connections::Photos
|
11
12
|
include Connections::Picture
|
12
13
|
include Connections::Posts
|
14
|
+
include Connections::Reviews
|
13
15
|
include Connections::Statuses
|
14
16
|
include Connections::Subscriptions
|
15
17
|
include Connections::Tagged
|
data/lib/fb_graph/auth/cookie.rb
CHANGED
@@ -6,10 +6,11 @@ module FbGraph
|
|
6
6
|
# If you want access token, use FbGraph::Auth.new(APP_ID, APP_SECRET, :cookie => {..}) instead
|
7
7
|
class Cookie
|
8
8
|
def self.parse(client, cookie)
|
9
|
-
fb_cookie_string =
|
10
|
-
|
11
|
-
else
|
9
|
+
fb_cookie_string = case cookie
|
10
|
+
when String
|
12
11
|
cookie
|
12
|
+
else
|
13
|
+
cookie["fbs_#{client.identifier}"]
|
13
14
|
end
|
14
15
|
|
15
16
|
raise VerificationFailed.new(401, 'Facebook cookie not found') if fb_cookie_string.blank?
|
@@ -5,7 +5,12 @@ module FbGraph
|
|
5
5
|
accounts = self.connection(:accounts, options)
|
6
6
|
accounts.map! do |account|
|
7
7
|
account[:access_token] ||= options[:access_token] || self.access_token
|
8
|
-
|
8
|
+
case self
|
9
|
+
when User
|
10
|
+
Page.new(account[:id], account)
|
11
|
+
when Application
|
12
|
+
TestUser.new(account[:id], account)
|
13
|
+
end
|
9
14
|
end
|
10
15
|
end
|
11
16
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module Docs
|
4
|
+
def docs(options = {})
|
5
|
+
docs = self.connection(:docs, options)
|
6
|
+
docs.map! do |doc|
|
7
|
+
Doc.new(doc[:id], doc.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -2,9 +2,12 @@ module FbGraph
|
|
2
2
|
module Connections
|
3
3
|
module Inbox
|
4
4
|
def inbox(options = {})
|
5
|
-
threads = self.connection(:
|
5
|
+
threads = self.connection(:inbox, options)
|
6
6
|
threads.map! do |thread|
|
7
|
-
|
7
|
+
# NOTE:
|
8
|
+
# Inbox API doesn't return thread object until their message platform becomes broadly available.
|
9
|
+
# Use Post instead of Thread for now.
|
10
|
+
Post.new(thread[:id], thread.merge(
|
8
11
|
:access_token => options[:access_token] || self.access_token
|
9
12
|
))
|
10
13
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module Outbox
|
4
|
+
def outbox(options = {})
|
5
|
+
threads = self.connection(:outbox, options)
|
6
|
+
threads.map! do |thread|
|
7
|
+
# NOTE:
|
8
|
+
# Inbox API doesn't return thread object until their message platform becomes broadly available.
|
9
|
+
# Use Post instead of Thread for now.
|
10
|
+
Post.new(thread[:id], thread.merge(
|
11
|
+
:access_token => options[:access_token] || self.access_token
|
12
|
+
))
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module Reviews
|
4
|
+
def reviews(options = {})
|
5
|
+
reviews = self.connection(:reviews, options)
|
6
|
+
reviews.map! do |review|
|
7
|
+
Review.new(review[:id], review.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module FbGraph
|
2
|
+
module Connections
|
3
|
+
module Threads
|
4
|
+
def threads(options = {})
|
5
|
+
threads = self.connection(:threads, options)
|
6
|
+
threads.map! do |thread|
|
7
|
+
Thread.new(thread[:id], thread.merge(
|
8
|
+
:access_token => options[:access_token] || self.access_token
|
9
|
+
))
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
data/lib/fb_graph/doc.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Doc < Node
|
3
|
+
attr_accessor :from, :subject, :icon, :updated_time, :revision
|
4
|
+
|
5
|
+
def initialize(identifier, attributes = {})
|
6
|
+
super
|
7
|
+
@from = if attributes[:from]
|
8
|
+
User.new(attributes[:from][:id], attributes[:from])
|
9
|
+
end
|
10
|
+
@subject = attributes[:subject]
|
11
|
+
@icon = attributes[:icon]
|
12
|
+
@revision = attributes[:revision]
|
13
|
+
@updated_time = if attributes[:updated_time]
|
14
|
+
Time.parse(attributes[:updated_time]).utc
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Domain < Node
|
3
|
+
include Connections::Insights
|
4
|
+
|
5
|
+
attr_accessor :name
|
6
|
+
|
7
|
+
def initialize(identifier, attributes = {})
|
8
|
+
super
|
9
|
+
@name = attributes[:name]
|
10
|
+
end
|
11
|
+
|
12
|
+
# NOTE:
|
13
|
+
# Don't use Searchable here.
|
14
|
+
# Domain search doesn't return paginatable array.
|
15
|
+
def self.search(domains)
|
16
|
+
fake_domain = 'fake.com'
|
17
|
+
domains = Array(domains)
|
18
|
+
unless domains.include?(fake_domain)
|
19
|
+
@using_fake = true
|
20
|
+
domains << fake_domain
|
21
|
+
end
|
22
|
+
results = Node.new(nil).send(:get, :domains => domains.join(','))
|
23
|
+
results = results.map do |identifier, attributes|
|
24
|
+
if @using_fake && attributes[:name] == fake_domain
|
25
|
+
next
|
26
|
+
end
|
27
|
+
new(identifier, attributes)
|
28
|
+
end
|
29
|
+
results.compact
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/fb_graph/group.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module FbGraph
|
2
2
|
class Group < Node
|
3
|
+
include Connections::Docs
|
3
4
|
include Connections::Feed
|
4
5
|
include Connections::Members
|
5
6
|
include Connections::Picture
|
6
7
|
include Connections::Videos
|
7
8
|
extend Searchable
|
8
9
|
|
9
|
-
attr_accessor :owner, :name, :description, :link, :icon, :
|
10
|
+
attr_accessor :owner, :name, :email, :description, :link, :icon, :privacy, :version, :updated_time
|
10
11
|
|
11
12
|
def initialize(identifier, attributes = {})
|
12
13
|
super
|
@@ -14,14 +15,12 @@ module FbGraph
|
|
14
15
|
@owner = User.new(owner[:id], owner)
|
15
16
|
end
|
16
17
|
@name = attributes[:name]
|
18
|
+
@email = attributes[:email]
|
17
19
|
@description = attributes[:description]
|
18
20
|
@link = attributes[:link]
|
19
21
|
@icon = attributes[:icon]
|
20
22
|
@privacy = attributes[:privacy]
|
21
23
|
@version = attributes[:version]
|
22
|
-
if attributes[:venue]
|
23
|
-
@venue = Venue.new(attributes[:venue])
|
24
|
-
end
|
25
24
|
if attributes[:updated_time]
|
26
25
|
@updated_time = Time.parse(attributes[:updated_time]).utc
|
27
26
|
end
|
data/lib/fb_graph/insight.rb
CHANGED
data/lib/fb_graph/link.rb
CHANGED
@@ -3,7 +3,7 @@ module FbGraph
|
|
3
3
|
include Connections::Comments
|
4
4
|
include Connections::Likes
|
5
5
|
|
6
|
-
attr_accessor :from, :link, :name, :
|
6
|
+
attr_accessor :from, :link, :name, :description, :icon, :picture, :message, :created_time
|
7
7
|
|
8
8
|
def initialize(identifier, attributes = {})
|
9
9
|
super
|
@@ -16,7 +16,6 @@ module FbGraph
|
|
16
16
|
end
|
17
17
|
@name = attributes[:name]
|
18
18
|
@link = attributes[:link]
|
19
|
-
@caption = attributes[:caption]
|
20
19
|
@description = attributes[:description]
|
21
20
|
@icon = attributes[:icon]
|
22
21
|
@picture = attributes[:picture] # NOTE: this is external image, so isn't connection.
|
data/lib/fb_graph/message.rb
CHANGED
@@ -5,11 +5,10 @@ module FbGraph
|
|
5
5
|
# include Connections::Shares
|
6
6
|
include Connections::Tags
|
7
7
|
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :message, :from, :to, :created_time
|
9
9
|
|
10
10
|
def initialize(identifier, attributes = {})
|
11
11
|
super
|
12
|
-
@subject = attributes[:subject]
|
13
12
|
@message = attributes[:message]
|
14
13
|
if (from = attributes[:from])
|
15
14
|
@from = User.new(from[:id], from)
|
@@ -20,12 +19,6 @@ module FbGraph
|
|
20
19
|
@to << User.new(to[:id], to)
|
21
20
|
end
|
22
21
|
end
|
23
|
-
@tags = []
|
24
|
-
if attributes[:tags]
|
25
|
-
Collection.new(attributes[:tags]).each do |tag|
|
26
|
-
@tags << Tag.new(tag)
|
27
|
-
end
|
28
|
-
end
|
29
22
|
if attributes[:created_time]
|
30
23
|
@created_time = Time.parse(attributes[:created_time]).utc
|
31
24
|
end
|
data/lib/fb_graph/node.rb
CHANGED
@@ -63,14 +63,14 @@ module FbGraph
|
|
63
63
|
|
64
64
|
def build_params(params)
|
65
65
|
_params_ = params.dup
|
66
|
-
_params_[:
|
66
|
+
_params_[:access_token] ||= self.access_token
|
67
67
|
_params_.delete_if do |k, v|
|
68
68
|
v.blank?
|
69
69
|
end
|
70
70
|
_params_.each do |key, value|
|
71
|
-
if value.present? && ![Symbol, String, Numeric, IO].any? { |klass| value.is_a? klass }
|
71
|
+
if value.present? && ![Symbol, String, Numeric, Rack::OAuth2::AccessToken::Legacy, IO].any? { |klass| value.is_a? klass }
|
72
72
|
_params_[key] = value.to_json
|
73
|
-
elsif [Symbol, Numeric].any? { |klass| value.is_a? klass }
|
73
|
+
elsif [Symbol, Numeric, Rack::OAuth2::AccessToken::Legacy].any? { |klass| value.is_a? klass }
|
74
74
|
_params_[key] = value.to_s
|
75
75
|
end
|
76
76
|
end
|
data/lib/fb_graph/post.rb
CHANGED
@@ -4,7 +4,7 @@ module FbGraph
|
|
4
4
|
include Connections::Likes
|
5
5
|
extend Searchable
|
6
6
|
|
7
|
-
attr_accessor :from, :to, :message, :picture, :link, :name, :caption, :description, :source, :
|
7
|
+
attr_accessor :from, :to, :message, :picture, :link, :name, :caption, :description, :source, :properties, :icon, :actions, :privacy, :type, :graph_object_id, :application, :targeting, :created_time, :updated_time
|
8
8
|
|
9
9
|
def initialize(identifier, attributes = {})
|
10
10
|
super
|
@@ -40,15 +40,19 @@ module FbGraph
|
|
40
40
|
@caption = attributes[:caption]
|
41
41
|
@description = attributes[:description]
|
42
42
|
@source = attributes[:source]
|
43
|
-
@
|
44
|
-
|
45
|
-
|
43
|
+
@properties = []
|
44
|
+
if attributes[:properties]
|
45
|
+
attributes[:properties].each do |property|
|
46
|
+
@properties << Property.new(property)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
@icon = attributes[:icon]
|
50
|
+
@actions = []
|
46
51
|
if attributes[:actions]
|
47
52
|
attributes[:actions].each do |action|
|
48
53
|
@actions << Action.new(action)
|
49
54
|
end
|
50
55
|
end
|
51
|
-
@type = attributes[:type]
|
52
56
|
if attributes[:privacy]
|
53
57
|
@privacy = if attributes[:privacy].is_a?(Privacy)
|
54
58
|
attributes[:privacy]
|
@@ -56,6 +60,11 @@ module FbGraph
|
|
56
60
|
Privacy.new(attributes[:privacy])
|
57
61
|
end
|
58
62
|
end
|
63
|
+
@type = attributes[:type]
|
64
|
+
@graph_object_id = attributes[:object_id]
|
65
|
+
if attributes[:application]
|
66
|
+
@application = Application.new(attributes[:application][:id], attributes[:application])
|
67
|
+
end
|
59
68
|
if attributes[:targeting]
|
60
69
|
@targeting = if attributes[:targeting].is_a?(Targeting)
|
61
70
|
attributes[:targeting]
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module FbGraph
|
2
|
+
class Review < Node
|
3
|
+
attr_accessor :from, :to, :message, :rating, :created_time
|
4
|
+
|
5
|
+
def initialize(identifier, attributes = {})
|
6
|
+
super
|
7
|
+
@from = if attributes[:from]
|
8
|
+
User.new(attributes[:from][:id], attributes[:from])
|
9
|
+
end
|
10
|
+
@to = if attributes[:to]
|
11
|
+
Application.new(attributes[:to][:id], attributes[:to])
|
12
|
+
end
|
13
|
+
@message = attributes[:message]
|
14
|
+
@rating = attributes[:rating]
|
15
|
+
@created_time = if attributes[:created_time]
|
16
|
+
Time.parse(attributes[:created_time]).utc
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/fb_graph/thread.rb
CHANGED
@@ -6,11 +6,10 @@ module FbGraph
|
|
6
6
|
include Connections::Senders
|
7
7
|
include Connections::Tags
|
8
8
|
|
9
|
-
attr_accessor :
|
9
|
+
attr_accessor :snippet, :message_count, :unread_count, :updated_time
|
10
10
|
|
11
11
|
def initialize(identifier, attributes = {})
|
12
12
|
super
|
13
|
-
@subject = attributes[:subject] # NOTE: New Facebook Message platform will make this field blank.
|
14
13
|
@snippet = attributes[:snippet]
|
15
14
|
@message_count = attributes[:message_count]
|
16
15
|
@unread_count = attributes[:unread_count].to_i
|
data/lib/fb_graph/user.rb
CHANGED
@@ -21,6 +21,7 @@ module FbGraph
|
|
21
21
|
include Connections::Movies
|
22
22
|
include Connections::Music
|
23
23
|
include Connections::Notes
|
24
|
+
include Connections::Outbox
|
24
25
|
include Connections::Payments
|
25
26
|
include Connections::Permissions
|
26
27
|
include Connections::Photos
|
@@ -29,29 +30,44 @@ module FbGraph
|
|
29
30
|
include Connections::Statuses
|
30
31
|
include Connections::Tagged
|
31
32
|
include Connections::Television
|
33
|
+
include Connections::Threads
|
32
34
|
include Connections::Videos
|
33
35
|
extend Searchable
|
34
36
|
|
35
|
-
attr_accessor :
|
37
|
+
attr_accessor :name, :first_name, :middle_name, :last_name, :gender, :locale, :languages, :link, :username, :third_party_id, :timezone, :updated_time, :verified, :about, :bio, :birthday, :education, :email, :hometown, :interested_in, :location, :political, :favorite_teams, :quotes, :relationship_status, :religion, :significant_other, :video_upload_limits, :website, :work
|
38
|
+
|
39
|
+
# NOTE: below are non-documented
|
40
|
+
attr_accessor :sports, :favorite_athletes, :inspirational_people, :address, :mobile_phone
|
36
41
|
|
37
42
|
def initialize(identifier, attributes = {})
|
38
43
|
super
|
39
|
-
@
|
40
|
-
@
|
41
|
-
@
|
42
|
-
@
|
43
|
-
@
|
44
|
+
@name = attributes[:name]
|
45
|
+
@first_name = attributes[:first_name]
|
46
|
+
@middle_name = attributes[:middle_name]
|
47
|
+
@last_name = attributes[:last_name]
|
48
|
+
@gender = attributes[:gender]
|
49
|
+
@locale = attributes[:locale]
|
50
|
+
@languages = []
|
51
|
+
if attributes[:languages]
|
52
|
+
attributes[:languages].each do |language|
|
53
|
+
@languages << Page.new(language[:id], language)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
@link = attributes[:link]
|
57
|
+
@username = attributes[:username]
|
58
|
+
@third_party_id = attributes[:third_party_id]
|
59
|
+
@timezone = attributes[:timezone]
|
60
|
+
if attributes[:updated_time]
|
61
|
+
@updated_time = Time.parse(attributes[:updated_time]).utc
|
62
|
+
end
|
63
|
+
@verified = attributes[:verified]
|
64
|
+
@about = attributes[:about]
|
65
|
+
@bio = attributes[:bio]
|
44
66
|
if attributes[:birthday]
|
45
67
|
month, day, year = attributes[:birthday].split('/').collect(&:to_i)
|
46
68
|
year ||= 0
|
47
69
|
@birthday = Date.new(year, month, day)
|
48
70
|
end
|
49
|
-
@work = []
|
50
|
-
if attributes[:work]
|
51
|
-
attributes[:work].each do |work|
|
52
|
-
@work << Work.new(work)
|
53
|
-
end
|
54
|
-
end
|
55
71
|
@education = []
|
56
72
|
if attributes[:education]
|
57
73
|
attributes[:education].each do |education|
|
@@ -59,25 +75,43 @@ module FbGraph
|
|
59
75
|
end
|
60
76
|
end
|
61
77
|
@email = attributes[:email]
|
62
|
-
@website = attributes[:website]
|
63
78
|
if (hometown = attributes[:hometown])
|
64
79
|
@hometown = Page.new(hometown[:id], hometown)
|
65
80
|
end
|
81
|
+
@interested_in = Array(attributes[:interested_in])
|
66
82
|
if (location = attributes[:location])
|
67
83
|
@location = Page.new(location[:id], location)
|
68
84
|
end
|
69
|
-
@
|
70
|
-
if (sports = attributes[:sports])
|
71
|
-
sports.each do |sport|
|
72
|
-
@sports << Page.new(sport[:id], sport)
|
73
|
-
end
|
74
|
-
end
|
85
|
+
@political = attributes[:political]
|
75
86
|
@favorite_teams = []
|
76
87
|
if attributes[:favorite_teams]
|
77
88
|
attributes[:favorite_teams].each do |favorite_team|
|
78
89
|
@favorite_teams << Page.new(favorite_team[:id], favorite_team)
|
79
90
|
end
|
80
91
|
end
|
92
|
+
@quotes = attributes[:quotes]
|
93
|
+
@relationship_status = attributes[:relationship_status]
|
94
|
+
@religion = attributes[:religion]
|
95
|
+
if (significant_other = attributes[:significant_other])
|
96
|
+
@significant_other = User.new(significant_other[:id], significant_other)
|
97
|
+
end
|
98
|
+
# NOTE: couldn't find "video_upload_limits" in the response..
|
99
|
+
# @video_upload_limits = ??
|
100
|
+
@website = attributes[:website]
|
101
|
+
@work = []
|
102
|
+
if attributes[:work]
|
103
|
+
attributes[:work].each do |work|
|
104
|
+
@work << Work.new(work)
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# NOTE: below are non-documented
|
109
|
+
@sports = []
|
110
|
+
if (sports = attributes[:sports])
|
111
|
+
sports.each do |sport|
|
112
|
+
@sports << Page.new(sport[:id], sport)
|
113
|
+
end
|
114
|
+
end
|
81
115
|
@favorite_athletes = []
|
82
116
|
if attributes[:favorite_athletes]
|
83
117
|
attributes[:favorite_athletes].each do |favorite_athlete|
|
@@ -90,31 +124,6 @@ module FbGraph
|
|
90
124
|
@inspirational_people << Page.new(inspirational_person[:id], inspirational_person)
|
91
125
|
end
|
92
126
|
end
|
93
|
-
@bio = attributes[:bio]
|
94
|
-
@quotes = attributes[:quotes]
|
95
|
-
@gender = attributes[:gender]
|
96
|
-
@interested_in = Array(attributes[:interested_in])
|
97
|
-
@meeting_for = Array(attributes[:meeting_for])
|
98
|
-
@relationship = attributes[:relationship]
|
99
|
-
@relationship_status = attributes[:relationship_status]
|
100
|
-
@religion = attributes[:religion]
|
101
|
-
@political = attributes[:political]
|
102
|
-
@verified = attributes[:verified]
|
103
|
-
if (significant_other = attributes[:significant_other])
|
104
|
-
@significant_other = User.new(significant_other[:id], significant_other)
|
105
|
-
end
|
106
|
-
@timezone = attributes[:timezone]
|
107
|
-
@locale = attributes[:locale]
|
108
|
-
@third_party_id = attributes[:third_party_id]
|
109
|
-
@languages = []
|
110
|
-
if attributes[:languages]
|
111
|
-
attributes[:languages].each do |language|
|
112
|
-
@languages << Page.new(language[:id], language)
|
113
|
-
end
|
114
|
-
end
|
115
|
-
if attributes[:updated_time]
|
116
|
-
@updated_time = Time.parse(attributes[:updated_time]).utc
|
117
|
-
end
|
118
127
|
if attributes[:address]
|
119
128
|
@address = Venue.new(attributes[:address])
|
120
129
|
end
|
data/lib/fb_graph/video.rb
CHANGED
@@ -2,8 +2,9 @@ module FbGraph
|
|
2
2
|
class Video < Node
|
3
3
|
include Connections::Comments
|
4
4
|
include Connections::Likes
|
5
|
+
include Connections::Picture
|
5
6
|
|
6
|
-
attr_accessor :from, :
|
7
|
+
attr_accessor :from, :tags, :name, :description, :embed_html, :icon, :source, :created_time, :updated_time
|
7
8
|
|
8
9
|
def initialize(identifier, attributes = {})
|
9
10
|
super
|
@@ -14,9 +15,17 @@ module FbGraph
|
|
14
15
|
User.new(from[:id], from)
|
15
16
|
end
|
16
17
|
end
|
17
|
-
@
|
18
|
+
@tags = []
|
19
|
+
if attributes[:tags]
|
20
|
+
Collection.new(attributes[:tags]).each do |tag|
|
21
|
+
@tags << Tag.new(tag)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
@name = attributes[:name]
|
18
25
|
@description = attributes[:description]
|
19
|
-
@
|
26
|
+
@embed_html = attributes[:embed_html]
|
27
|
+
@icon = attributes[:icon]
|
28
|
+
@source = attributes[:source]
|
20
29
|
if attributes[:created_time]
|
21
30
|
@created_time = Time.parse(attributes[:created_time]).utc
|
22
31
|
end
|
data/lib/fb_graph.rb
CHANGED
@@ -61,6 +61,8 @@ require 'fb_graph/app_request'
|
|
61
61
|
require 'fb_graph/application'
|
62
62
|
require 'fb_graph/checkin'
|
63
63
|
require 'fb_graph/comment'
|
64
|
+
require 'fb_graph/doc'
|
65
|
+
require 'fb_graph/domain'
|
64
66
|
require 'fb_graph/event'
|
65
67
|
require 'fb_graph/friend_list'
|
66
68
|
require 'fb_graph/group'
|
@@ -74,6 +76,8 @@ require 'fb_graph/page'
|
|
74
76
|
require 'fb_graph/photo'
|
75
77
|
require 'fb_graph/place'
|
76
78
|
require 'fb_graph/post'
|
79
|
+
require 'fb_graph/property'
|
80
|
+
require 'fb_graph/review'
|
77
81
|
require 'fb_graph/status'
|
78
82
|
require 'fb_graph/tag'
|
79
83
|
require 'fb_graph/thread'
|
data/spec/fb_graph/album_spec.rb
CHANGED
@@ -15,6 +15,7 @@ describe FbGraph::Album do
|
|
15
15
|
:location => 'Tokyo, Japan',
|
16
16
|
:link => 'http://www.facebook.com/album/12345',
|
17
17
|
:count => 10,
|
18
|
+
:cover_photo => '10150146072661729',
|
18
19
|
:type => 'normal',
|
19
20
|
:created_time => '2009-12-29T15:24:50+0000',
|
20
21
|
:updated_time => '2010-01-02T15:37:41+0000',
|
@@ -37,6 +38,7 @@ describe FbGraph::Album do
|
|
37
38
|
album.description.should == 'an album for fb_graph test'
|
38
39
|
album.location.should == 'Tokyo, Japan'
|
39
40
|
album.link.should == 'http://www.facebook.com/album/12345'
|
41
|
+
album.cover_photo.should == FbGraph::Photo.new('10150146072661729')
|
40
42
|
album.count.should == 10
|
41
43
|
album.type.should == 'normal'
|
42
44
|
album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
|
@@ -8,12 +8,23 @@ describe FbGraph::Auth::Cookie, '.parse' do
|
|
8
8
|
}
|
9
9
|
end
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
11
|
+
shared_examples_for :parsable_cookie do
|
12
|
+
it 'should be parsable' do
|
13
|
+
cookie[:access_token].should == 't'
|
14
|
+
cookie[:expires].should == 0
|
15
|
+
cookie[:secret].should == 's'
|
16
|
+
cookie[:session_key].should == 'k'
|
17
|
+
cookie[:uid].should == '12345'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when whole cookie is given' do
|
22
|
+
let(:cookie) { FbGraph::Auth::Cookie.parse(@client, @cookie) }
|
23
|
+
it_behaves_like :parsable_cookie
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when actual cookie string is given' do
|
27
|
+
let(:cookie) { FbGraph::Auth::Cookie.parse(@client, @cookie['fbs_client_id']) }
|
28
|
+
it_behaves_like :parsable_cookie
|
18
29
|
end
|
19
30
|
end
|