fb_graph2 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/fb_graph2/app_link_host.rb +1 -1
- data/lib/fb_graph2/attribute_assigner.rb +6 -6
- data/lib/fb_graph2/collection.rb +29 -4
- data/lib/fb_graph2/edge.rb +20 -0
- data/lib/fb_graph2/edge/accounts.rb +1 -1
- data/lib/fb_graph2/edge/achievements.rb +1 -1
- data/lib/fb_graph2/edge/activities.rb +1 -1
- data/lib/fb_graph2/edge/admins.rb +1 -1
- data/lib/fb_graph2/edge/albums.rb +1 -1
- data/lib/fb_graph2/edge/app_event_types.rb +1 -1
- data/lib/fb_graph2/edge/app_link_hosts.rb +1 -1
- data/lib/fb_graph2/edge/app_requests.rb +1 -1
- data/lib/fb_graph2/edge/applications.rb +1 -1
- data/lib/fb_graph2/edge/attending.rb +1 -1
- data/lib/fb_graph2/edge/banned.rb +1 -1
- data/lib/fb_graph2/edge/blocked.rb +1 -1
- data/lib/fb_graph2/edge/books.rb +1 -1
- data/lib/fb_graph2/edge/comments.rb +1 -1
- data/lib/fb_graph2/edge/declined.rb +1 -1
- data/lib/fb_graph2/edge/docs.rb +1 -1
- data/lib/fb_graph2/edge/events.rb +1 -1
- data/lib/fb_graph2/edge/family.rb +1 -1
- data/lib/fb_graph2/edge/feed.rb +1 -1
- data/lib/fb_graph2/edge/files.rb +1 -1
- data/lib/fb_graph2/edge/friend_lists.rb +1 -1
- data/lib/fb_graph2/edge/friends.rb +6 -1
- data/lib/fb_graph2/edge/games.rb +1 -1
- data/lib/fb_graph2/edge/global_brand_children.rb +1 -1
- data/lib/fb_graph2/edge/groups.rb +1 -1
- data/lib/fb_graph2/edge/home.rb +1 -1
- data/lib/fb_graph2/edge/inbox.rb +1 -1
- data/lib/fb_graph2/edge/interests.rb +1 -1
- data/lib/fb_graph2/edge/invitable_friends.rb +1 -1
- data/lib/fb_graph2/edge/invited.rb +1 -1
- data/lib/fb_graph2/edge/likes.rb +2 -2
- data/lib/fb_graph2/edge/links.rb +1 -1
- data/lib/fb_graph2/edge/locations.rb +1 -1
- data/lib/fb_graph2/edge/maybe.rb +1 -1
- data/lib/fb_graph2/edge/members.rb +1 -1
- data/lib/fb_graph2/edge/milestones.rb +1 -1
- data/lib/fb_graph2/edge/movies.rb +1 -1
- data/lib/fb_graph2/edge/music.rb +1 -1
- data/lib/fb_graph2/edge/noreply.rb +1 -1
- data/lib/fb_graph2/edge/notifications.rb +1 -1
- data/lib/fb_graph2/edge/offers.rb +1 -1
- data/lib/fb_graph2/edge/outbox.rb +1 -1
- data/lib/fb_graph2/edge/payment_transactions.rb +1 -1
- data/lib/fb_graph2/edge/permissions.rb +1 -1
- data/lib/fb_graph2/edge/photos.rb +1 -1
- data/lib/fb_graph2/edge/pokes.rb +1 -1
- data/lib/fb_graph2/edge/posts.rb +1 -1
- data/lib/fb_graph2/edge/promotable_posts.rb +1 -1
- data/lib/fb_graph2/edge/roles.rb +1 -1
- data/lib/fb_graph2/edge/scores.rb +1 -1
- data/lib/fb_graph2/edge/shared_posts.rb +1 -1
- data/lib/fb_graph2/edge/static_resources.rb +1 -1
- data/lib/fb_graph2/edge/statuses.rb +1 -1
- data/lib/fb_graph2/edge/subscriptions.rb +1 -1
- data/lib/fb_graph2/edge/taggable_friends.rb +1 -1
- data/lib/fb_graph2/edge/tagged.rb +1 -1
- data/lib/fb_graph2/edge/tagged_places.rb +1 -1
- data/lib/fb_graph2/edge/tags.rb +1 -1
- data/lib/fb_graph2/edge/television.rb +1 -1
- data/lib/fb_graph2/edge/test_users.rb +1 -1
- data/lib/fb_graph2/edge/translations.rb +1 -1
- data/lib/fb_graph2/edge/videos.rb +1 -1
- data/lib/fb_graph2/struct/app_event_type.rb +1 -1
- data/spec/fb_graph2/edge/accounts_spec.rb +1 -0
- data/spec/fb_graph2/edge/achievements_spec.rb +1 -0
- data/spec/fb_graph2/edge/activities_spec.rb +1 -0
- data/spec/fb_graph2/edge/admins_spec.rb +1 -0
- data/spec/fb_graph2/edge/albums_spec.rb +1 -0
- data/spec/fb_graph2/edge/blocked_spec.rb +1 -0
- data/spec/fb_graph2/edge/books_spec.rb +1 -0
- data/spec/fb_graph2/edge/comments_spec.rb +1 -0
- data/spec/fb_graph2/edge/events_spec.rb +1 -0
- data/spec/fb_graph2/edge/feed_spec.rb +1 -0
- data/spec/fb_graph2/edge/friend_lists_spec.rb +1 -0
- data/spec/fb_graph2/edge/friends_spec.rb +21 -1
- data/spec/fb_graph2/edge/groups_spec.rb +1 -0
- data/spec/fb_graph2/edge/home_spec.rb +1 -0
- data/spec/fb_graph2/edge/interests_spec.rb +1 -0
- data/spec/fb_graph2/edge/invitable_friends_spec.rb +1 -0
- data/spec/fb_graph2/edge/likes_spec.rb +3 -1
- data/spec/fb_graph2/edge/links_spec.rb +1 -0
- data/spec/fb_graph2/edge/milestones_spec.rb +1 -0
- data/spec/fb_graph2/edge/movies_spec.rb +1 -0
- data/spec/fb_graph2/edge/music_spec.rb +1 -0
- data/spec/fb_graph2/edge/notifications_spec.rb +1 -0
- data/spec/fb_graph2/edge/permissions_spec.rb +1 -0
- data/spec/fb_graph2/edge/photos_spec.rb +1 -0
- data/spec/fb_graph2/edge/pokes_spec.rb +1 -0
- data/spec/fb_graph2/edge/posts_spec.rb +1 -0
- data/spec/fb_graph2/edge/promotable_posts_spec.rb +1 -0
- data/spec/fb_graph2/edge/scores_spec.rb +1 -0
- data/spec/fb_graph2/edge/shared_posts_spec.rb +1 -0
- data/spec/fb_graph2/edge/statuses_spec.rb +1 -0
- data/spec/fb_graph2/edge/subscriptions_spec.rb +1 -0
- data/spec/fb_graph2/edge/taggable_friends_spec.rb +1 -0
- data/spec/fb_graph2/edge/television_spec.rb +1 -0
- data/spec/fb_graph2/edge/test_users_spec.rb +1 -0
- data/spec/fb_graph2/edge/videos_spec.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b5101130cc02d8296b40d43431d7ee92fa1376a5
|
|
4
|
+
data.tar.gz: 68d6ec8b8aa8d4902f51d22d4a4ba516c673c54d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 707151ca14d7eb56451c033971e29bf7cd626558da847902dca2db66861a0e7e0b3e84da75ae2572573bcb5329871f24a58c75aea0f698af3cd80a55e7131081
|
|
7
|
+
data.tar.gz: ca94244c9da577f2a5b7a806c3cf32c7bec77cc7a80b8992b816a0da8db1510f34426d83e5a501d359ff5933bde611156ac2c72e2e09ad932e2020d1d7ec5a3d
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.1.
|
|
1
|
+
0.1.1
|
|
@@ -17,7 +17,7 @@ module FbGraph2
|
|
|
17
17
|
private
|
|
18
18
|
|
|
19
19
|
def collect_links(attributes, link_attr)
|
|
20
|
-
Collection.new(attributes[link_attr]).collect do |link|
|
|
20
|
+
Collection.new(attributes[link_attr]).collect! do |link|
|
|
21
21
|
klass = case link_attr
|
|
22
22
|
when :ios, :iphone, :ipad
|
|
23
23
|
Struct::AppLink::Native::IOS
|
|
@@ -33,7 +33,7 @@ module FbGraph2
|
|
|
33
33
|
when :timestamp
|
|
34
34
|
Time.at raw
|
|
35
35
|
when :actions
|
|
36
|
-
Collection.new(raw).collect do |_raw_|
|
|
36
|
+
Collection.new(raw).collect! do |_raw_|
|
|
37
37
|
Struct::Action.new _raw_
|
|
38
38
|
end
|
|
39
39
|
when :album
|
|
@@ -45,17 +45,17 @@ module FbGraph2
|
|
|
45
45
|
when :group
|
|
46
46
|
Group.new raw[:id], raw
|
|
47
47
|
when :image_sources
|
|
48
|
-
Collection.new(raw).collect do |_raw_|
|
|
48
|
+
Collection.new(raw).collect! do |_raw_|
|
|
49
49
|
Struct::ImageSource.new _raw_
|
|
50
50
|
end
|
|
51
51
|
when :messages
|
|
52
|
-
Collection.new(raw).collect do |_raw_|
|
|
52
|
+
Collection.new(raw).collect! do |_raw_|
|
|
53
53
|
Message.new _raw_[:id], _raw_
|
|
54
54
|
end
|
|
55
55
|
when :page
|
|
56
56
|
Page.new raw[:id], raw
|
|
57
57
|
when :pages
|
|
58
|
-
Collection.new(raw).collect do |_raw_|
|
|
58
|
+
Collection.new(raw).collect! do |_raw_|
|
|
59
59
|
Page.new _raw_[:id], _raw_
|
|
60
60
|
end
|
|
61
61
|
when :photo
|
|
@@ -65,13 +65,13 @@ module FbGraph2
|
|
|
65
65
|
when :profile
|
|
66
66
|
as_profile raw
|
|
67
67
|
when :profiles
|
|
68
|
-
Collection.new(raw).collect do |_raw_|
|
|
68
|
+
Collection.new(raw).collect! do |_raw_|
|
|
69
69
|
as_profile _raw_
|
|
70
70
|
end
|
|
71
71
|
when :user
|
|
72
72
|
User.new raw[:id], raw
|
|
73
73
|
when :users
|
|
74
|
-
Collection.new(raw).collect do |_raw_|
|
|
74
|
+
Collection.new(raw).collect! do |_raw_|
|
|
75
75
|
User.new _raw_[:id], _raw_
|
|
76
76
|
end
|
|
77
77
|
else
|
data/lib/fb_graph2/collection.rb
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
module FbGraph2
|
|
2
2
|
class Collection < Array
|
|
3
|
-
|
|
3
|
+
attr_accessor :before, :after, :next, :previous
|
|
4
4
|
|
|
5
|
-
def initialize(collection)
|
|
6
|
-
collection =
|
|
5
|
+
def initialize(collection = [])
|
|
6
|
+
collection = normalize collection
|
|
7
|
+
setup_pagination collection[:paging]
|
|
8
|
+
replace Array(collection[:data])
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
private
|
|
12
|
+
|
|
13
|
+
def normalize(collection)
|
|
14
|
+
case collection
|
|
7
15
|
when Hash
|
|
8
16
|
collection
|
|
9
17
|
when Array
|
|
@@ -14,7 +22,24 @@ module FbGraph2
|
|
|
14
22
|
else
|
|
15
23
|
raise ArgumentError.new("Invalid collection")
|
|
16
24
|
end
|
|
17
|
-
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def setup_pagination(paging)
|
|
28
|
+
cursors = paging.try(:[], :cursors)
|
|
29
|
+
self.before = cursors.try(:[], :before)
|
|
30
|
+
self.after = cursors.try(:[], :after)
|
|
31
|
+
self.next = params_in paging.try(:[], :next)
|
|
32
|
+
self.previous = params_in paging.try(:[], :previous)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def params_in(url)
|
|
36
|
+
if url
|
|
37
|
+
Rack::Utils.parse_nested_query(
|
|
38
|
+
URI.parse(url).query
|
|
39
|
+
).inject({}) do |params, (key, value)|
|
|
40
|
+
params.merge! key => value
|
|
41
|
+
end.with_indifferent_access
|
|
42
|
+
end
|
|
18
43
|
end
|
|
19
44
|
end
|
|
20
45
|
end
|
data/lib/fb_graph2/edge.rb
CHANGED
|
@@ -10,6 +10,26 @@ module FbGraph2
|
|
|
10
10
|
self.collection = options.delete(:collection) || Collection.new
|
|
11
11
|
replace collection
|
|
12
12
|
end
|
|
13
|
+
|
|
14
|
+
def next(_options_ = {})
|
|
15
|
+
if collection.next.present?
|
|
16
|
+
owner.send edge, options.merge(collection.next).merge(_options_)
|
|
17
|
+
elsif collection.after.present?
|
|
18
|
+
owner.send edge, options.merge(after: collection.after).merge(_options_)
|
|
19
|
+
else
|
|
20
|
+
self.class.new owner, edge
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def previous(_options_ = {})
|
|
25
|
+
if self.collection.previous.present?
|
|
26
|
+
owner.send edge, options.merge(collection.previous).merge(_options_)
|
|
27
|
+
elsif collection.before.present?
|
|
28
|
+
owner.send edge, options.merge(before: collection.before).merge(_options_)
|
|
29
|
+
else
|
|
30
|
+
self.class.new owner, edge
|
|
31
|
+
end
|
|
32
|
+
end
|
|
13
33
|
end
|
|
14
34
|
end
|
|
15
35
|
|
|
@@ -3,7 +3,7 @@ module FbGraph2
|
|
|
3
3
|
module Achievements
|
|
4
4
|
def achievements(params = {})
|
|
5
5
|
achievements = self.edge :achievements, params
|
|
6
|
-
achievements.collect do |achievement|
|
|
6
|
+
achievements.collect! do |achievement|
|
|
7
7
|
Achievement.new(achievement[:id], achievement).authenticate self.access_token
|
|
8
8
|
end
|
|
9
9
|
end
|
data/lib/fb_graph2/edge/books.rb
CHANGED
data/lib/fb_graph2/edge/docs.rb
CHANGED
data/lib/fb_graph2/edge/feed.rb
CHANGED
data/lib/fb_graph2/edge/files.rb
CHANGED
|
@@ -3,7 +3,7 @@ module FbGraph2
|
|
|
3
3
|
module FriendLists
|
|
4
4
|
def friend_lists(params = {})
|
|
5
5
|
friend_lists = self.edge :friendlists, params
|
|
6
|
-
friend_lists.collect do |friend_list|
|
|
6
|
+
friend_lists.collect! do |friend_list|
|
|
7
7
|
FriendList.new(friend_list[:id], friend_list).authenticate self.access_token
|
|
8
8
|
end
|
|
9
9
|
end
|
|
@@ -3,10 +3,15 @@ module FbGraph2
|
|
|
3
3
|
module Friends
|
|
4
4
|
def friends(params = {})
|
|
5
5
|
users = self.edge :friends, params
|
|
6
|
-
users.collect do |user|
|
|
6
|
+
users.collect! do |user|
|
|
7
7
|
User.new(user[:id], user).authenticate self.access_token
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
def friend?(user, params = {})
|
|
12
|
+
users = self.edge :friends, params, edge_scope: user
|
|
13
|
+
users.present?
|
|
14
|
+
end
|
|
10
15
|
end
|
|
11
16
|
end
|
|
12
17
|
end
|
data/lib/fb_graph2/edge/games.rb
CHANGED
data/lib/fb_graph2/edge/home.rb
CHANGED
data/lib/fb_graph2/edge/inbox.rb
CHANGED