1
0
Fork 0
mirror of https://github.com/nov/fb_graph2 synced 2023-03-27 23:22:15 -04:00

User#taggable_friends

close #12
This commit is contained in:
nov 2014-08-15 11:08:01 +09:00
parent 5aa9d710d4
commit 00d7133c95
8 changed files with 72 additions and 14 deletions

View file

@ -3,8 +3,8 @@ module FbGraph2
module InvitableFriends
def invitable_friends(params = {})
invitable_friends = self.edge :invitable_friends, params
invitable_friends.collect do |invitable_friend|
Struct::InvitableFriend.new invitable_friend
invitable_friends.collect do |friend|
Struct::Friend.new friend
end
end
end

View file

@ -0,0 +1,12 @@
module FbGraph2
class Edge
module TaggableFriends
def taggable_friends(params = {})
taggable_friends = self.edge :taggable_friends, params
taggable_friends.collect do |friend|
Struct::Friend.new friend
end
end
end
end
end

View file

@ -0,0 +1,10 @@
module FbGraph2
class Struct
class Friend < Struct
register_attributes(
raw: [:id, :name], # NOTE: this 'id' isn't user_id, but a token for invitation/tagging.
picture: [:picture]
)
end
end
end

View file

@ -1,10 +0,0 @@
module FbGraph2
class Struct
class InvitableFriend < Struct
register_attributes(
raw: [:id, :name],
picture: [:picture]
)
end
end
end

View file

@ -32,6 +32,7 @@ module FbGraph2
include Edge::Posts
include Edge::Scores
include Edge::Statuses
include Edge::TaggableFriends
include Edge::Tagged
include Edge::TaggedPlaces
include Edge::Television

View file

@ -4,13 +4,13 @@ describe FbGraph2::Edge::InvitableFriends do
context 'included in User' do
describe '#invitable_friends' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Struct::InvitableFriend' do
it 'should return an Array of FbGraph2::Struct::Friend' do
users = mock_graph :get, 'me/invitable_friends', 'user/invitable_friends', access_token: 'token' do
me.invitable_friends
end
users.should_not be_blank
users.each do |user|
user.should be_instance_of FbGraph2::Struct::InvitableFriend
user.should be_instance_of FbGraph2::Struct::Friend
end
end
end

View file

@ -0,0 +1,18 @@
require 'spec_helper'
describe FbGraph2::Edge::TaggableFriends do
context 'included in User' do
describe '#taggable_friends' do
let(:me) { FbGraph2::User.me('token') }
it 'should return an Array of FbGraph2::Struct::Friend' do
users = mock_graph :get, 'me/taggable_friends', 'user/taggable_friends', access_token: 'token' do
me.taggable_friends
end
users.should_not be_blank
users.each do |user|
user.should be_instance_of FbGraph2::Struct::Friend
end
end
end
end
end

View file

@ -0,0 +1,27 @@
{
"data": [{
"id": "AVm6afobc20T0wATmCYRk_CNymo_44MQW8yMBwpgDFAQ18iF9feZpDEDmwfmcjSBSSuYkFfD5fx77g_uJRF0fmQ7AR2kObX8biP4wzN7UMpbYQ",
"name": "Shingo Yamanaka",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/t1.0-1/c0.15.85.85/s50x50/1468668_10152037195781416_2050550170_s.jpg"
}
}
}, {
"id": "AVnJiIlmAtrWJ106ErRPlLZNy8_Hd4mfmuQBrbGm4tuFS_ENvyYdVxTwgesXE5Wp2ICtxcPHzkA4Y4BJAWwJqyUie2ZDKQeKn9mnjPCVAUr8Lg",
"name": "Hayashi Tatsuya",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/t1.0-1/c79.38.479.479/s50x50/388771_10150501378984825_523522119_n.jpg"
}
}
}],
"paging": {
"cursors": {
"before": "QVZra09GaExkNndsM1J5eVpuQ2dWS1hLV3FBb0dqRTh3dC1PVXJIZE8ya0JzbV9kUDZXcWZEdUtUZFNHejcxeGlWZ3JjZjZjdkIwMWdtSWtHZGpGVE8wTWZ5cUdNUm5NWWw3c2hSTEtPZ19ySmc=",
"after": "QVZrdlNsUHItNExPY1JIUVdlZ3BDZlFCTHFFMUl6YVhnVG5fRVlBLVV0QThUMFBmRnZNQkVQWVg2VkRBQWhRa3RyemVQUFhscWxBVERYZU15SExZbG50Z0RTQUtfVno5VjRjT3VUb2J5NGg1VFE="
}
}
}