fb_graph 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.0
1
+ 1.0.0
data/fb_graph.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "0.8.0"
8
+ s.version = "1.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  "lib/fb_graph/connections/albums.rb",
43
43
  "lib/fb_graph/connections/attending.rb",
44
44
  "lib/fb_graph/connections/books.rb",
45
+ "lib/fb_graph/connections/checkins.rb",
45
46
  "lib/fb_graph/connections/comments.rb",
46
47
  "lib/fb_graph/connections/declined.rb",
47
48
  "lib/fb_graph/connections/events.rb",
@@ -98,6 +99,8 @@ Gem::Specification.new do |s|
98
99
  "spec/fake_json/events/maybe/smartday_private.json",
99
100
  "spec/fake_json/events/noreply/smartday_private.json",
100
101
  "spec/fake_json/groups/members/emacs_private.json",
102
+ "spec/fake_json/pages/checkins/gowalla_private.json",
103
+ "spec/fake_json/pages/checkins/gowalla_public.json",
101
104
  "spec/fake_json/pages/notes/post_with_valid_access_token.json",
102
105
  "spec/fake_json/pages/platform_private.json",
103
106
  "spec/fake_json/pages/platform_public.json",
@@ -123,6 +126,8 @@ Gem::Specification.new do |s|
123
126
  "spec/fake_json/users/arjun_public.json",
124
127
  "spec/fake_json/users/books/matake_private.json",
125
128
  "spec/fake_json/users/books/matake_public.json",
129
+ "spec/fake_json/users/checkins/mattt_private.json",
130
+ "spec/fake_json/users/checkins/mattt_public.json",
126
131
  "spec/fake_json/users/events/matake_private.json",
127
132
  "spec/fake_json/users/events/matake_public.json",
128
133
  "spec/fake_json/users/events/post_with_valid_access_token.json",
@@ -164,6 +169,7 @@ Gem::Specification.new do |s|
164
169
  "spec/fb_graph/album_spec.rb",
165
170
  "spec/fb_graph/application_spec.rb",
166
171
  "spec/fb_graph/auth_spec.rb",
172
+ "spec/fb_graph/checkin_spec.rb",
167
173
  "spec/fb_graph/collection_spec.rb",
168
174
  "spec/fb_graph/comment_spec.rb",
169
175
  "spec/fb_graph/connection_spec.rb",
@@ -172,6 +178,7 @@ Gem::Specification.new do |s|
172
178
  "spec/fb_graph/connections/albums_spec.rb",
173
179
  "spec/fb_graph/connections/attending_spec.rb",
174
180
  "spec/fb_graph/connections/books_spec.rb",
181
+ "spec/fb_graph/connections/checkins_spec.rb",
175
182
  "spec/fb_graph/connections/comments_spec.rb",
176
183
  "spec/fb_graph/connections/declined_spec.rb",
177
184
  "spec/fb_graph/connections/events_spec.rb",
@@ -225,6 +232,7 @@ Gem::Specification.new do |s|
225
232
  "spec/fb_graph/album_spec.rb",
226
233
  "spec/fb_graph/application_spec.rb",
227
234
  "spec/fb_graph/auth_spec.rb",
235
+ "spec/fb_graph/checkin_spec.rb",
228
236
  "spec/fb_graph/collection_spec.rb",
229
237
  "spec/fb_graph/comment_spec.rb",
230
238
  "spec/fb_graph/connection_spec.rb",
@@ -233,6 +241,7 @@ Gem::Specification.new do |s|
233
241
  "spec/fb_graph/connections/albums_spec.rb",
234
242
  "spec/fb_graph/connections/attending_spec.rb",
235
243
  "spec/fb_graph/connections/books_spec.rb",
244
+ "spec/fb_graph/connections/checkins_spec.rb",
236
245
  "spec/fb_graph/connections/comments_spec.rb",
237
246
  "spec/fb_graph/connections/declined_spec.rb",
238
247
  "spec/fb_graph/connections/events_spec.rb",
@@ -1,5 +1,7 @@
1
1
  module FbGraph
2
2
  class Checkin < Node
3
+ extend Searchable
4
+
3
5
  attr_accessor :from, :tags, :place, :message, :coordinates, :application, :created_time
4
6
 
5
7
  def initialize(identifier, attributes = {})
@@ -7,9 +9,36 @@ module FbGraph
7
9
  if (from = attributes[:from])
8
10
  @from = FbGraph::User.new(from.delete(:id), from)
9
11
  end
10
- # TODO
11
- # Checkin isn't available in Japan yet, so I can't use this feature yet.
12
- # I'm very glad if someone helps me here.
12
+ @tags = []
13
+ if (tags = attributes[:tags])
14
+ FbGraph::Collection.new(tags).each do |user|
15
+ @tags << FbGraph::User.new(user.delete(:id), user)
16
+ end
17
+ end
18
+ if (location = attributes[:location])
19
+ @location = FbGraph::Page.new(location.delete(:id), location)
20
+ end
21
+ @message = attributes[:message]
22
+ if (coordinates = attributes[:coordinates])
23
+ # NOTE: it seems this attributes isn't used now
24
+ @coordinates = FbGraph::Venue.new(location)
25
+ end
26
+ if (application = attributes[:application])
27
+ @application = FbGraph::Application.new(application.delete(:id), application)
28
+ end
29
+ if (created_time = attributes.delete(:created_time))
30
+ @created_time = Time.parse(created_time).utc
31
+ end
32
+ end
33
+
34
+ # = Search for recent check-ins for an authorized user and his or her friends:
35
+ #
36
+ # FbGraph::Checkin.search(:access_token => ACCESS_TOKEN)
37
+ # => Array of FbGraph::Checkin
38
+ def self.search(options = {})
39
+ # NOTE:
40
+ # checkin search doesn't support "q=***" parameter
41
+ super(nil, options)
13
42
  end
14
43
  end
15
44
  end
@@ -0,0 +1,22 @@
1
+ module FbGraph
2
+ module Connections
3
+ # == Fetch checkins
4
+ #
5
+ # * To get a user's check-ins, request the "user_checkins".
6
+ # * To see the user's friends' check-ins, request the "friends_checkins".
7
+ # ref) http://developers.facebook.com/docs/api#places
8
+ #
9
+ # FbGraph::User.new("matake").checkins(:access_token => ACCESS_TOKEN)
10
+ # FbGraph::Page.new("Tokyo").checkins(:access_token => ACCESS_TOKEN)
11
+ module Checkins
12
+ def checkins(options = {})
13
+ checkins = self.connection(:checkins, options)
14
+ checkins.map! do |checkin|
15
+ FbGraph::Checkin.new(checkin.delete(:id), checkin.merge(
16
+ :access_token => options[:access_token] || self.access_token
17
+ ))
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -20,6 +20,7 @@ module FbGraph
20
20
  # See details at "Subscription Verification" in the Facebook API document.
21
21
  # ref) http://developers.facebook.com/docs/api/realtime
22
22
  #
23
+ # app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
23
24
  # app.subscribe!(
24
25
  # :object => "user",
25
26
  # :fields => "name,email",
@@ -38,6 +39,7 @@ module FbGraph
38
39
  # If you specify an object parameter, it will only delete the corresponding subscription.
39
40
  # ref) http://developers.facebook.com/docs/api/realtime
40
41
  #
42
+ # app = FbGraph::Application.new(APP_ID, :secret => APP_SECRET)
41
43
  # app.unsubscribe!(
42
44
  # :object => "user"
43
45
  # )
@@ -7,20 +7,20 @@ module FbGraph
7
7
 
8
8
  attr_accessor :owner, :name, :description, :link, :venue, :privacy, :updated_time
9
9
 
10
- def initialize(identifier, options = {})
10
+ def initialize(identifier, attributes = {})
11
11
  super
12
- if (owner = options[:owner])
12
+ if (owner = attributes[:owner])
13
13
  @owner = FbGraph::User.new(owner.delete(:id), owner)
14
14
  end
15
- @name = options[:name]
16
- @description = options[:description]
17
- @link = options[:link]
18
- @privacy = options[:privacy]
19
- if options[:venue]
20
- @venue = FbGraph::Venue.new(options[:venue])
15
+ @name = attributes[:name]
16
+ @description = attributes[:description]
17
+ @link = attributes[:link]
18
+ @privacy = attributes[:privacy]
19
+ if attributes[:venue]
20
+ @venue = FbGraph::Venue.new(attributes[:venue])
21
21
  end
22
- if options[:updated_time]
23
- @updated_time = Time.parse(options[:updated_time]).utc
22
+ if attributes[:updated_time]
23
+ @updated_time = Time.parse(attributes[:updated_time]).utc
24
24
  end
25
25
  end
26
26
  end
data/lib/fb_graph/node.rb CHANGED
@@ -105,7 +105,7 @@ module FbGraph
105
105
  _response_ = JSON.parse(response.body).with_indifferent_access
106
106
  if _response_[:error]
107
107
  case _response_[:error][:type]
108
- when 'OAuthAccessTokenException', 'QueryParseException', 'OAuthInvalidRequestException'
108
+ when 'OAuthAccessTokenException', 'QueryParseException', 'OAuthInvalidRequestException', 'OAuthInvalidTokenException'
109
109
  raise FbGraph::Unauthorized.new(_response_[:error][:message])
110
110
  else
111
111
  raise FbGraph::BadRequest.new("#{_response_[:error][:type]} :: #{_response_[:error][:message]}")
data/lib/fb_graph/page.rb CHANGED
@@ -13,9 +13,10 @@ module FbGraph
13
13
  include Connections::Posts
14
14
  include Connections::Members
15
15
  include Connections::Events
16
+ include Connections::Checkins
16
17
  extend Searchable
17
18
 
18
- attr_accessor :name, :username, :link, :category, :founded, :company_overview, :mission, :products, :fan_count
19
+ attr_accessor :name, :username, :link, :category, :founded, :company_overview, :mission, :products, :fan_count, :location
19
20
 
20
21
  def initialize(identifier, attributes = {})
21
22
  super
@@ -32,6 +33,9 @@ module FbGraph
32
33
  @products = products.split "\n"
33
34
  end
34
35
  @fan_count = attributes[:fan_count]
36
+ if (location = attributes[:location])
37
+ @venue = FbGraph::Venue.new(location)
38
+ end
35
39
  end
36
40
  end
37
41
  end
@@ -5,17 +5,17 @@ module FbGraph
5
5
 
6
6
  attr_accessor :from, :message, :updated_time
7
7
 
8
- def initialize(identifier, options = {})
8
+ def initialize(identifier, attributes = {})
9
9
  super
10
- if (from = options[:from])
10
+ if (from = attributes[:from])
11
11
  @from = if from[:category]
12
12
  FbGraph::Page.new(from.delete(:id), from)
13
13
  else
14
14
  FbGraph::User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
- @message = options[:message]
18
- if (updated_time = options.delete(:updated_time))
17
+ @message = attributes[:message]
18
+ if (updated_time = attributes.delete(:updated_time))
19
19
  @updated_time = Time.parse(updated_time).utc
20
20
  end
21
21
  end
data/lib/fb_graph/tag.rb CHANGED
@@ -4,13 +4,13 @@ module FbGraph
4
4
 
5
5
  attr_accessor :user, :x, :y, :created_time
6
6
 
7
- def initialize(identifier, options = {})
8
- @x = options.delete(:x)
9
- @y = options.delete(:y)
10
- if (created_time = options.delete(:created_time))
7
+ def initialize(identifier, attributes = {})
8
+ @x = attributes.delete(:x)
9
+ @y = attributes.delete(:y)
10
+ if (created_time = attributes.delete(:created_time))
11
11
  @created_time = Time.parse(created_time).utc
12
12
  end
13
- @user = User.new(identifier, options)
13
+ @user = User.new(identifier, attributes)
14
14
  end
15
15
  end
16
16
  end
data/lib/fb_graph/user.rb CHANGED
@@ -26,57 +26,58 @@ module FbGraph
26
26
  # include Connections::Inbox
27
27
  # include Connections::Outbox
28
28
  # include Connections::Updates
29
- include Connections::Accounts
30
29
  # ++
30
+ include Connections::Accounts
31
+ include Connections::Checkins
31
32
  extend Searchable
32
33
 
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
34
35
 
35
- def initialize(identifier, options = {})
36
+ def initialize(identifier, attributes = {})
36
37
  super
37
- @first_name = options[:first_name]
38
- @last_name = options[:last_name]
39
- @name = options[:name]
40
- @link = options[:link]
41
- @about = options[:about]
42
- if options[:birthday]
43
- month, day, year = options[:birthday].split('/').collect(&:to_i)
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)
44
45
  year ||= 0
45
46
  @birthday = Date.new(year, month, day)
46
47
  end
47
48
  @work = []
48
- if options[:work]
49
- options[:work].each do |work|
49
+ if attributes[:work]
50
+ attributes[:work].each do |work|
50
51
  @work << FbGraph::Work.new(work)
51
52
  end
52
53
  end
53
54
  @education = []
54
- if options[:education]
55
- options[:education].each do |education|
55
+ if attributes[:education]
56
+ attributes[:education].each do |education|
56
57
  @education << FbGraph::Education.new(education)
57
58
  end
58
59
  end
59
- @email = options[:email]
60
- @website = options[:website].to_s.split("\n")
61
- if (hometown = options[:hometown])
60
+ @email = attributes[:email]
61
+ @website = attributes[:website].to_s.split("\n")
62
+ if (hometown = attributes[:hometown])
62
63
  @hometown = FbGraph::Page.new(hometown.delete(:id), hometown)
63
64
  end
64
- if (location = options[:location])
65
+ if (location = attributes[:location])
65
66
  @location = FbGraph::Page.new(location.delete(:id), location)
66
67
  end
67
- @bio = options[:bio]
68
- @quotes = options[:quotes]
69
- @gender = options[:gender]
70
- @interested_in = Array(options[:interested_in])
71
- @meeting_for = Array(options[:meeting_for])
72
- @relationship_status = options[:relationship_status]
73
- @religion = options[:religion]
74
- @political = options[:political]
75
- @verified = options[:verified]
76
- @significant_other = options[:significant_other] # What's this??
77
- @timezone = options[:timezone]
78
- if options[:updated_time]
79
- @updated_time = Time.parse(options[:updated_time]).utc
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
80
81
  end
81
82
  end
82
83
 
@@ -5,23 +5,23 @@ module FbGraph
5
5
 
6
6
  attr_accessor :from, :message, :description, :length, :created_time, :updated_time
7
7
 
8
- def initialize(identifier, options = {})
8
+ def initialize(identifier, attributes = {})
9
9
  super
10
- if (from = options[:from])
10
+ if (from = attributes[:from])
11
11
  @from = if from[:category]
12
12
  FbGraph::Page.new(from.delete(:id), from)
13
13
  else
14
14
  FbGraph::User.new(from.delete(:id), from)
15
15
  end
16
16
  end
17
- @message = options[:message]
18
- @description = options[:description]
19
- @length = options[:length]
20
- if options[:created_time]
21
- @created_time = Time.parse(options[:created_time]).utc
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
22
  end
23
- if options[:updated_time]
24
- @updated_time = Time.parse(options[:updated_time]).utc
23
+ if attributes[:updated_time]
24
+ @updated_time = Time.parse(attributes[:updated_time]).utc
25
25
  end
26
26
  end
27
27
  end
data/lib/fb_graph.rb CHANGED
@@ -55,6 +55,7 @@ require 'fb_graph/searchable'
55
55
  require 'fb_graph/node'
56
56
  require 'fb_graph/album'
57
57
  require 'fb_graph/application'
58
+ require 'fb_graph/checkin'
58
59
  require 'fb_graph/comment'
59
60
  require 'fb_graph/education'
60
61
  require 'fb_graph/event'
@@ -0,0 +1,113 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "696876187499",
5
+ "from": {
6
+ "name": "Roger Pincombe",
7
+ "id": "12820552"
8
+ },
9
+ "tags": {
10
+ "data": [
11
+ {
12
+ "name": "Mattt Thompson",
13
+ "id": "4810308"
14
+ }
15
+ ]
16
+ },
17
+ "message": "Checking out Austin, TX",
18
+ "place": {
19
+ "id": "120454134658381",
20
+ "name": "Gowalla HQ",
21
+ "location": {
22
+ "latitude": 30.26876,
23
+ "longitude": -97.74962
24
+ }
25
+ },
26
+ "application": {
27
+ "name": "Facebook for iPhone",
28
+ "id": "6628568379"
29
+ },
30
+ "created_time": "2010-09-08T00:09:25+0000"
31
+ },
32
+ {
33
+ "id": "463895351674",
34
+ "from": {
35
+ "name": "Scott Raymond",
36
+ "id": "505421674"
37
+ },
38
+ "tags": {
39
+ "data": [
40
+ {
41
+ "name": "Mattt Thompson",
42
+ "id": "4810308"
43
+ },
44
+ {
45
+ "name": "Sandi Weldon",
46
+ "id": "695370206"
47
+ }
48
+ ]
49
+ },
50
+ "place": {
51
+ "id": "120454134658381",
52
+ "name": "Gowalla HQ",
53
+ "location": {
54
+ "latitude": 30.26876,
55
+ "longitude": -97.74962
56
+ }
57
+ },
58
+ "application": {
59
+ "name": "Facebook for iPhone",
60
+ "id": "6628568379"
61
+ },
62
+ "created_time": "2010-08-20T22:33:26+0000"
63
+ },
64
+ {
65
+ "id": "461099202106",
66
+ "from": {
67
+ "name": "John Marstall",
68
+ "id": "752752106"
69
+ },
70
+ "tags": {
71
+ "data": [
72
+ {
73
+ "name": "Mattt Thompson",
74
+ "id": "4810308"
75
+ },
76
+ {
77
+ "name": "Phillip Bowden",
78
+ "id": "25316885"
79
+ },
80
+ {
81
+ "name": "Brian Bailey",
82
+ "id": "526567227"
83
+ },
84
+ {
85
+ "name": "John Critz",
86
+ "id": "805120116"
87
+ },
88
+ {
89
+ "name": "Keegan Jones",
90
+ "id": "1304370418"
91
+ }
92
+ ]
93
+ },
94
+ "place": {
95
+ "id": "120454134658381",
96
+ "name": "Gowalla HQ",
97
+ "location": {
98
+ "latitude": 30.26876,
99
+ "longitude": -97.74962
100
+ }
101
+ },
102
+ "application": {
103
+ "name": "Facebook for iPhone",
104
+ "id": "6628568379"
105
+ },
106
+ "created_time": "2010-08-19T19:46:24+0000"
107
+ }
108
+ ],
109
+ "paging": {
110
+ "previous": "https://graph.facebook.com/120454134658381/checkins?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&since=2010-09-08T00%3A09%3A25%2B0000",
111
+ "next": "https://graph.facebook.com/120454134658381/checkins?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&until=2010-08-19T19%3A46%3A23%2B0000"
112
+ }
113
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "error": {
3
+ "type": "OAuthInvalidTokenException",
4
+ "message": "An access token is required to request this resource."
5
+ }
6
+ }
@@ -0,0 +1,389 @@
1
+ {
2
+ "data": [
3
+ {
4
+ "id": "696876187499",
5
+ "from": {
6
+ "name": "Roger Pincombe",
7
+ "id": "12820552"
8
+ },
9
+ "tags": {
10
+ "data": [
11
+ {
12
+ "name": "Mattt Thompson",
13
+ "id": "4810308"
14
+ }
15
+ ]
16
+ },
17
+ "message": "Checking out Austin, TX",
18
+ "place": {
19
+ "id": "120454134658381",
20
+ "name": "Gowalla HQ",
21
+ "location": {
22
+ "latitude": 30.26876,
23
+ "longitude": -97.74962
24
+ }
25
+ },
26
+ "application": {
27
+ "name": "Facebook for iPhone",
28
+ "id": "6628568379"
29
+ },
30
+ "created_time": "2010-09-08T00:09:25+0000"
31
+ },
32
+ {
33
+ "id": "701128934833",
34
+ "from": {
35
+ "name": "Sarah Smith",
36
+ "id": "222574"
37
+ },
38
+ "tags": {
39
+ "data": [
40
+ {
41
+ "name": "Mattt Thompson",
42
+ "id": "4810308"
43
+ },
44
+ {
45
+ "name": "Keegan Jones",
46
+ "id": "1304370418"
47
+ }
48
+ ]
49
+ },
50
+ "message": "Pretty good DJ",
51
+ "place": {
52
+ "id": "140580665977144",
53
+ "name": "halcyon",
54
+ "location": {
55
+ "latitude": 30.267038941383,
56
+ "longitude": -97.745790481567
57
+ }
58
+ },
59
+ "application": {
60
+ "name": "Facebook for iPhone",
61
+ "id": "6628568379"
62
+ },
63
+ "created_time": "2010-09-04T01:52:54+0000"
64
+ },
65
+ {
66
+ "id": "611783578689",
67
+ "from": {
68
+ "name": "Mattt Thompson",
69
+ "id": "4810308"
70
+ },
71
+ "place": {
72
+ "id": "111665838868969",
73
+ "name": "Elephant Room",
74
+ "location": {
75
+ "street": "315 Congress Ave",
76
+ "city": "Austin",
77
+ "state": "TX",
78
+ "zip": "78701-4032",
79
+ "latitude": 30.265453,
80
+ "longitude": -97.743661
81
+ }
82
+ },
83
+ "application": {
84
+ "name": "Facebook for iPhone",
85
+ "id": "6628568379"
86
+ },
87
+ "created_time": "2010-09-02T04:04:34+0000",
88
+ "comments": {
89
+ "data": [
90
+ {
91
+ "id": "611783578689_603913",
92
+ "from": {
93
+ "name": "Glenn D Banton Sr.",
94
+ "id": "100001008400197"
95
+ },
96
+ "message": "Past tense.. \"was\"?",
97
+ "created_time": "2010-09-02T16:00:55+0000"
98
+ },
99
+ {
100
+ "id": "611783578689_604315",
101
+ "from": {
102
+ "name": "Mattt Thompson",
103
+ "id": "4810308"
104
+ },
105
+ "message": "Yeah, Facebook loves them some correct tenses.",
106
+ "created_time": "2010-09-02T20:45:41+0000"
107
+ }
108
+ ],
109
+ "paging": {
110
+ "previous": "https://graph.facebook.com/611783578689/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&since=2010-09-02T20%3A45%3A41%2B0000",
111
+ "next": "https://graph.facebook.com/611783578689/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&until=2010-09-02T16%3A00%3A54%2B0000"
112
+ }
113
+ }
114
+ },
115
+ {
116
+ "id": "610883667119",
117
+ "from": {
118
+ "name": "Mattt Thompson",
119
+ "id": "4810308"
120
+ },
121
+ "place": {
122
+ "id": "139045549463750",
123
+ "name": "The Ginger Man",
124
+ "location": {
125
+ "latitude": 30.266271416667,
126
+ "longitude": -97.74553775
127
+ }
128
+ },
129
+ "application": {
130
+ "name": "Facebook for iPhone",
131
+ "id": "6628568379"
132
+ },
133
+ "created_time": "2010-08-26T22:48:57+0000",
134
+ "comments": {
135
+ "data": [
136
+ {
137
+ "id": "610883667119_594123",
138
+ "from": {
139
+ "name": "Jenn Vargas",
140
+ "id": "419222"
141
+ },
142
+ "message": "jealousssss",
143
+ "created_time": "2010-08-27T07:22:24+0000"
144
+ },
145
+ {
146
+ "id": "610883667119_594693",
147
+ "from": {
148
+ "name": "Sharon Wong",
149
+ "id": "4806450"
150
+ },
151
+ "message": "I love that place!",
152
+ "created_time": "2010-08-27T17:52:13+0000"
153
+ }
154
+ ],
155
+ "paging": {
156
+ "previous": "https://graph.facebook.com/610883667119/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&since=2010-08-27T17%3A52%3A13%2B0000",
157
+ "next": "https://graph.facebook.com/610883667119/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&until=2010-08-27T07%3A22%3A23%2B0000"
158
+ }
159
+ }
160
+ },
161
+ {
162
+ "id": "699014073033",
163
+ "from": {
164
+ "name": "Sarah Smith",
165
+ "id": "222574"
166
+ },
167
+ "tags": {
168
+ "data": [
169
+ {
170
+ "name": "Mattt Thompson",
171
+ "id": "4810308"
172
+ },
173
+ {
174
+ "name": "Maggie Cook",
175
+ "id": "11404163"
176
+ }
177
+ ]
178
+ },
179
+ "message": "I admit I am here thanks to a Gowalla notification email :)",
180
+ "place": {
181
+ "id": "139045549463750",
182
+ "name": "The Ginger Man",
183
+ "location": {
184
+ "latitude": 30.266271416667,
185
+ "longitude": -97.74553775
186
+ }
187
+ },
188
+ "application": {
189
+ "name": "Facebook for iPhone",
190
+ "id": "6628568379"
191
+ },
192
+ "created_time": "2010-08-26T03:14:26+0000",
193
+ "likes": {
194
+ "data": [
195
+ {
196
+ "id": "630266137",
197
+ "name": "Tom Watson"
198
+ }
199
+ ]
200
+ },
201
+ "comments": {
202
+ "data": [
203
+ {
204
+ "id": "699014073033_1045588",
205
+ "from": {
206
+ "name": "Brooke Segaran",
207
+ "id": "685395130"
208
+ },
209
+ "message": "i love the Ginger Man! I think they have a sister bar in Houston - it was one of my favorites when I lived there.",
210
+ "created_time": "2010-08-26T15:38:02+0000"
211
+ }
212
+ ],
213
+ "paging": {
214
+ "previous": "https://graph.facebook.com/699014073033/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&since=2010-08-26T15%3A38%3A02%2B0000",
215
+ "next": "https://graph.facebook.com/699014073033/comments?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&until=2010-08-26T15%3A38%3A01%2B0000"
216
+ }
217
+ }
218
+ },
219
+ {
220
+ "id": "610777350179",
221
+ "from": {
222
+ "name": "Mattt Thompson",
223
+ "id": "4810308"
224
+ },
225
+ "place": {
226
+ "id": "139045549463750",
227
+ "name": "The Ginger Man",
228
+ "location": {
229
+ "latitude": 30.266271416667,
230
+ "longitude": -97.74553775
231
+ }
232
+ },
233
+ "application": {
234
+ "name": "Facebook for iPhone",
235
+ "id": "6628568379"
236
+ },
237
+ "created_time": "2010-08-26T02:27:11+0000",
238
+ "likes": {
239
+ "data": [
240
+ {
241
+ "id": "788861822",
242
+ "name": "Kim Ahlstr\u00f6m"
243
+ }
244
+ ]
245
+ }
246
+ },
247
+ {
248
+ "id": "610294378059",
249
+ "from": {
250
+ "name": "Mattt Thompson",
251
+ "id": "4810308"
252
+ },
253
+ "place": {
254
+ "id": "121133247902315",
255
+ "name": "Caffe Medici",
256
+ "location": {
257
+ "street": "1101 W Lynn St",
258
+ "city": "Austin",
259
+ "state": "TX",
260
+ "zip": "78703-3951",
261
+ "latitude": 30.279843,
262
+ "longitude": -97.759178
263
+ }
264
+ },
265
+ "application": {
266
+ "name": "Facebook for iPhone",
267
+ "id": "6628568379"
268
+ },
269
+ "created_time": "2010-08-23T01:40:17+0000"
270
+ },
271
+ {
272
+ "id": "463895351674",
273
+ "from": {
274
+ "name": "Scott Raymond",
275
+ "id": "505421674"
276
+ },
277
+ "tags": {
278
+ "data": [
279
+ {
280
+ "name": "Mattt Thompson",
281
+ "id": "4810308"
282
+ },
283
+ {
284
+ "name": "Sandi Weldon",
285
+ "id": "695370206"
286
+ }
287
+ ]
288
+ },
289
+ "place": {
290
+ "id": "120454134658381",
291
+ "name": "Gowalla HQ",
292
+ "location": {
293
+ "latitude": 30.26876,
294
+ "longitude": -97.74962
295
+ }
296
+ },
297
+ "application": {
298
+ "name": "Facebook for iPhone",
299
+ "id": "6628568379"
300
+ },
301
+ "created_time": "2010-08-20T22:33:26+0000"
302
+ },
303
+ {
304
+ "id": "10100357716724694",
305
+ "from": {
306
+ "name": "Patrick Navarro",
307
+ "id": "8300721"
308
+ },
309
+ "tags": {
310
+ "data": [
311
+ {
312
+ "name": "Mattt Thompson",
313
+ "id": "4810308"
314
+ },
315
+ {
316
+ "name": "Maggie Cook",
317
+ "id": "11404163"
318
+ },
319
+ {
320
+ "name": "Drew Yeaton",
321
+ "id": "65005613"
322
+ }
323
+ ]
324
+ },
325
+ "message": "Twitter Happy Hour",
326
+ "place": {
327
+ "id": "118824551503801",
328
+ "name": "Union park",
329
+ "location": {
330
+ "latitude": 30.26986587,
331
+ "longitude": -97.74904483
332
+ }
333
+ },
334
+ "application": {
335
+ "name": "Facebook for iPhone",
336
+ "id": "6628568379"
337
+ },
338
+ "created_time": "2010-08-19T23:36:55+0000"
339
+ },
340
+ {
341
+ "id": "461099202106",
342
+ "from": {
343
+ "name": "John Marstall",
344
+ "id": "752752106"
345
+ },
346
+ "tags": {
347
+ "data": [
348
+ {
349
+ "name": "Mattt Thompson",
350
+ "id": "4810308"
351
+ },
352
+ {
353
+ "name": "Phillip Bowden",
354
+ "id": "25316885"
355
+ },
356
+ {
357
+ "name": "Brian Bailey",
358
+ "id": "526567227"
359
+ },
360
+ {
361
+ "name": "John Critz",
362
+ "id": "805120116"
363
+ },
364
+ {
365
+ "name": "Keegan Jones",
366
+ "id": "1304370418"
367
+ }
368
+ ]
369
+ },
370
+ "place": {
371
+ "id": "120454134658381",
372
+ "name": "Gowalla HQ",
373
+ "location": {
374
+ "latitude": 30.26876,
375
+ "longitude": -97.74962
376
+ }
377
+ },
378
+ "application": {
379
+ "name": "Facebook for iPhone",
380
+ "id": "6628568379"
381
+ },
382
+ "created_time": "2010-08-19T19:46:24+0000"
383
+ }
384
+ ],
385
+ "paging": {
386
+ "previous": "https://graph.facebook.com/4810308/checkins?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&since=2010-09-08T00%3A09%3A25%2B0000",
387
+ "next": "https://graph.facebook.com/4810308/checkins?access_token=134145643294322%7Ce31f8c85a0ad9e63018eb051-579612276%7CgwSx9WAssLi5sW3vqqe8UPGjchY.&limit=25&until=2010-08-19T19%3A46%3A23%2B0000"
388
+ }
389
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "error": {
3
+ "type": "OAuthInvalidTokenException",
4
+ "message": "An access token is required to request this resource."
5
+ }
6
+ }
@@ -0,0 +1,5 @@
1
+ require File.join(File.dirname(__FILE__), '../spec_helper')
2
+
3
+ describe FbGraph::Checkin, '.new' do
4
+ # TODO
5
+ end
@@ -0,0 +1,109 @@
1
+ require File.join(File.dirname(__FILE__), '../../spec_helper')
2
+
3
+ context 'when included by FbGraph::User' do
4
+ describe FbGraph::Connections::Checkins, '#checkins' do
5
+ before(:all) do
6
+ fake_json(:get, 'mattt/checkins', 'users/checkins/mattt_public')
7
+ fake_json(:get, 'mattt/checkins?access_token=access_token', 'users/checkins/mattt_private')
8
+ end
9
+
10
+ context 'when no access_token given' do
11
+ it 'should raise FbGraph::Unauthorized' do
12
+ lambda do
13
+ FbGraph::User.new('mattt').checkins
14
+ end.should raise_exception(FbGraph::Unauthorized)
15
+ end
16
+ end
17
+
18
+ context 'when access_token is given' do
19
+ it 'should return checkins as FbGraph::Checkin' do
20
+ checkins = FbGraph::User.new('mattt', :access_token => 'access_token').checkins
21
+ checkins.first.should == FbGraph::Checkin.new(
22
+ '696876187499',
23
+ :access_token => 'access_token',
24
+ :from => {
25
+ :id => '12820552',
26
+ :name => 'Roger Pincombe'
27
+ },
28
+ :tags => {
29
+ :data => [{
30
+ :id => '4810308',
31
+ :name => 'Mattt Thompson'
32
+ }]
33
+ },
34
+ :message => 'Checking out Austin, TX',
35
+ :place => {
36
+ :id => '120454134658381',
37
+ :name => 'Gowalla HQ',
38
+ :location => {
39
+ :latitude => 30.26876,
40
+ :longitude => -97.74962
41
+ }
42
+ },
43
+ :application => {
44
+ :id => '6628568379',
45
+ :name => 'Facebook for iPhone'
46
+ },
47
+ :created_time => '2010-09-08T00:09:25+0000'
48
+ )
49
+ checkins.each do |checkin|
50
+ checkin.should be_instance_of(FbGraph::Checkin)
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ context 'when included by FbGraph::Page' do
58
+ describe FbGraph::Connections::Checkins, '#checkins' do
59
+ before(:all) do
60
+ fake_json(:get, 'gowalla/checkins', 'pages/checkins/gowalla_public')
61
+ fake_json(:get, 'gowalla/checkins?access_token=access_token', 'pages/checkins/gowalla_private')
62
+ end
63
+
64
+ context 'when no access_token given' do
65
+ it 'should raise FbGraph::Unauthorized' do
66
+ lambda do
67
+ FbGraph::Page.new('gowalla').checkins
68
+ end.should raise_exception(FbGraph::Unauthorized)
69
+ end
70
+ end
71
+
72
+ context 'when access_token is given' do
73
+ it 'should return checkins as FbGraph::Checkin' do
74
+ checkins = FbGraph::Page.new('gowalla', :access_token => 'access_token').checkins
75
+ checkins.first.should == FbGraph::Checkin.new(
76
+ '696876187499',
77
+ :access_token => 'access_token',
78
+ :from => {
79
+ :id => '12820552',
80
+ :name => 'Roger Pincombe'
81
+ },
82
+ :tags => {
83
+ :data => [{
84
+ :id => '4810308',
85
+ :name => 'Mattt Thompson'
86
+ }]
87
+ },
88
+ :message => 'Checking out Austin, TX',
89
+ :place => {
90
+ :id => '120454134658381',
91
+ :name => 'Gowalla HQ',
92
+ :location => {
93
+ :latitude => 30.26876,
94
+ :longitude => -97.74962
95
+ }
96
+ },
97
+ :application => {
98
+ :id => '6628568379',
99
+ :name => 'Facebook for iPhone'
100
+ },
101
+ :created_time => '2010-09-08T00:09:25+0000'
102
+ )
103
+ checkins.each do |checkin|
104
+ checkin.should be_instance_of(FbGraph::Checkin)
105
+ end
106
+ end
107
+ end
108
+ end
109
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 63
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
+ - 1
7
8
  - 0
8
- - 8
9
9
  - 0
10
- version: 0.8.0
10
+ version: 1.0.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -154,6 +154,7 @@ files:
154
154
  - lib/fb_graph/connections/albums.rb
155
155
  - lib/fb_graph/connections/attending.rb
156
156
  - lib/fb_graph/connections/books.rb
157
+ - lib/fb_graph/connections/checkins.rb
157
158
  - lib/fb_graph/connections/comments.rb
158
159
  - lib/fb_graph/connections/declined.rb
159
160
  - lib/fb_graph/connections/events.rb
@@ -210,6 +211,8 @@ files:
210
211
  - spec/fake_json/events/maybe/smartday_private.json
211
212
  - spec/fake_json/events/noreply/smartday_private.json
212
213
  - spec/fake_json/groups/members/emacs_private.json
214
+ - spec/fake_json/pages/checkins/gowalla_private.json
215
+ - spec/fake_json/pages/checkins/gowalla_public.json
213
216
  - spec/fake_json/pages/notes/post_with_valid_access_token.json
214
217
  - spec/fake_json/pages/platform_private.json
215
218
  - spec/fake_json/pages/platform_public.json
@@ -235,6 +238,8 @@ files:
235
238
  - spec/fake_json/users/arjun_public.json
236
239
  - spec/fake_json/users/books/matake_private.json
237
240
  - spec/fake_json/users/books/matake_public.json
241
+ - spec/fake_json/users/checkins/mattt_private.json
242
+ - spec/fake_json/users/checkins/mattt_public.json
238
243
  - spec/fake_json/users/events/matake_private.json
239
244
  - spec/fake_json/users/events/matake_public.json
240
245
  - spec/fake_json/users/events/post_with_valid_access_token.json
@@ -276,6 +281,7 @@ files:
276
281
  - spec/fb_graph/album_spec.rb
277
282
  - spec/fb_graph/application_spec.rb
278
283
  - spec/fb_graph/auth_spec.rb
284
+ - spec/fb_graph/checkin_spec.rb
279
285
  - spec/fb_graph/collection_spec.rb
280
286
  - spec/fb_graph/comment_spec.rb
281
287
  - spec/fb_graph/connection_spec.rb
@@ -284,6 +290,7 @@ files:
284
290
  - spec/fb_graph/connections/albums_spec.rb
285
291
  - spec/fb_graph/connections/attending_spec.rb
286
292
  - spec/fb_graph/connections/books_spec.rb
293
+ - spec/fb_graph/connections/checkins_spec.rb
287
294
  - spec/fb_graph/connections/comments_spec.rb
288
295
  - spec/fb_graph/connections/declined_spec.rb
289
296
  - spec/fb_graph/connections/events_spec.rb
@@ -365,6 +372,7 @@ test_files:
365
372
  - spec/fb_graph/album_spec.rb
366
373
  - spec/fb_graph/application_spec.rb
367
374
  - spec/fb_graph/auth_spec.rb
375
+ - spec/fb_graph/checkin_spec.rb
368
376
  - spec/fb_graph/collection_spec.rb
369
377
  - spec/fb_graph/comment_spec.rb
370
378
  - spec/fb_graph/connection_spec.rb
@@ -373,6 +381,7 @@ test_files:
373
381
  - spec/fb_graph/connections/albums_spec.rb
374
382
  - spec/fb_graph/connections/attending_spec.rb
375
383
  - spec/fb_graph/connections/books_spec.rb
384
+ - spec/fb_graph/connections/checkins_spec.rb
376
385
  - spec/fb_graph/connections/comments_spec.rb
377
386
  - spec/fb_graph/connections/declined_spec.rb
378
387
  - spec/fb_graph/connections/events_spec.rb