fb_graph2 0.0.11 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b4f60a4edc36068c5e05c3b7e63431744ab0da6c
4
- data.tar.gz: b5fa5048e0e41fe3f9264038dc3c028ab323a086
3
+ metadata.gz: cc5d3c2c9db1f215157ae1db4631bc68713a8acd
4
+ data.tar.gz: 4bdda11d0b45da1de00c6d047c0aaa18d0bcebcf
5
5
  SHA512:
6
- metadata.gz: 0e07ffef61980cc47920ef52472d7000bd54879f45fa48eb4d4734622d86d03e906b39140971efd9943c601bc90207fa2b34e2e6368e950517f31d98ea720a4c
7
- data.tar.gz: 5c3e5d12925f9e802522438446c609d6a82cf28b2e413c7c77db62967285c45ff78ad8f65dabee1681b46d7f3ec519936fc7ff689709fa8a8e44ede8222437cc
6
+ metadata.gz: 1da28587bf9edf922972307a8d163f42e8e3df5d27a468104c6080d293f81c2371ab945d14b805aa9df7936366ec4f0182e028785d83538d1e3f4da57de0dd17
7
+ data.tar.gz: a5618e8d32e7f9d6a51c7a9f56e6c14054c9db4ceb2e105c5ea8607731673f50453cc972296b72f48568263d27bed64b7b13249db5055ad0a9974a18d62fe62b
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.11
1
+ 0.1.0
@@ -27,7 +27,7 @@ module FbGraph2
27
27
  client_auth_method: :body
28
28
  )
29
29
  rescue Rack::OAuth2::Client::Error => e
30
- raise Exception.detect_from_status(detect_from_status).new(e.message)
30
+ raise Exception.detect_from_status(e.status).new(e.message)
31
31
  end
32
32
  end
33
33
  end
@@ -3,8 +3,8 @@ module FbGraph2
3
3
  module InvitableFriends
4
4
  def invitable_friends(params = {})
5
5
  invitable_friends = self.edge :invitable_friends, params
6
- invitable_friends.collect do |invitable_friend|
7
- Struct::InvitableFriend.new invitable_friend
6
+ invitable_friends.collect do |friend|
7
+ Struct::Friend.new friend
8
8
  end
9
9
  end
10
10
  end
@@ -9,8 +9,7 @@ module FbGraph2
9
9
  end
10
10
 
11
11
  def notification!(params = {})
12
- notification = self.post params, edge: :notifications
13
- notification.include? :success
12
+ self.post params, edge: :notifications
14
13
  end
15
14
  alias_method :notify!, :notification!
16
15
  end
@@ -0,0 +1,12 @@
1
+ module FbGraph2
2
+ class Edge
3
+ module TaggableFriends
4
+ def taggable_friends(params = {})
5
+ taggable_friends = self.edge :taggable_friends, params
6
+ taggable_friends.collect do |friend|
7
+ Struct::Friend.new friend
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -112,7 +112,11 @@ module FbGraph2
112
112
  _response_ = _response_.with_indifferent_access if _response_.respond_to? :with_indifferent_access
113
113
  case response.status
114
114
  when 200...300
115
- _response_
115
+ if _response_.respond_to?(:include?) && _response_.include?(:success)
116
+ _response_[:success]
117
+ else
118
+ _response_
119
+ end
116
120
  else
117
121
  raise Exception.detect(response.status, _response_, response.headers)
118
122
  end
@@ -0,0 +1,10 @@
1
+ module FbGraph2
2
+ class Struct
3
+ class Friend < Struct
4
+ register_attributes(
5
+ raw: [:id, :name], # NOTE: this 'id' isn't user_id, but a token for invitation/tagging.
6
+ picture: [:picture]
7
+ )
8
+ end
9
+ end
10
+ end
@@ -32,6 +32,7 @@ module FbGraph2
32
32
  include Edge::Posts
33
33
  include Edge::Scores
34
34
  include Edge::Statuses
35
+ include Edge::TaggableFriends
35
36
  include Edge::Tagged
36
37
  include Edge::TaggedPlaces
37
38
  include Edge::Television
@@ -4,13 +4,13 @@ describe FbGraph2::Edge::InvitableFriends do
4
4
  context 'included in User' do
5
5
  describe '#invitable_friends' do
6
6
  let(:me) { FbGraph2::User.me('token') }
7
- it 'should return an Array of FbGraph2::Struct::InvitableFriend' do
7
+ it 'should return an Array of FbGraph2::Struct::Friend' do
8
8
  users = mock_graph :get, 'me/invitable_friends', 'user/invitable_friends', access_token: 'token' do
9
9
  me.invitable_friends
10
10
  end
11
11
  users.should_not be_blank
12
12
  users.each do |user|
13
- user.should be_instance_of FbGraph2::Struct::InvitableFriend
13
+ user.should be_instance_of FbGraph2::Struct::Friend
14
14
  end
15
15
  end
16
16
  end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ describe FbGraph2::Edge::TaggableFriends do
4
+ context 'included in User' do
5
+ describe '#taggable_friends' do
6
+ let(:me) { FbGraph2::User.me('token') }
7
+ it 'should return an Array of FbGraph2::Struct::Friend' do
8
+ users = mock_graph :get, 'me/taggable_friends', 'user/taggable_friends', access_token: 'token' do
9
+ me.taggable_friends
10
+ end
11
+ users.should_not be_blank
12
+ users.each do |user|
13
+ user.should be_instance_of FbGraph2::Struct::Friend
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -18,6 +18,19 @@ describe FbGraph2::User do
18
18
  end
19
19
  me.should be_instance_of klass
20
20
  end
21
+
22
+ context 'when ext attrs included' do
23
+ it 'should success to parse' do
24
+ me = mock_graph :get, 'me', 'user/me_with_ext_attrs' do
25
+ klass.me('token').fetch
26
+ end
27
+ [
28
+ :age_range, :context, :currency, :devices
29
+ ].each do |key|
30
+ me.send(key).should be_present
31
+ end
32
+ end
33
+ end
21
34
  end
22
35
  end
23
36
  end
@@ -0,0 +1,65 @@
1
+ {
2
+ "age_range": {
3
+ "min": 21
4
+ },
5
+ "context": {
6
+ "mutual_friends": {
7
+ "data": [],
8
+ "summary": {
9
+ "total_count": 245
10
+ }
11
+ },
12
+ "mutual_likes": {
13
+ "data": [{
14
+ "category": "Product/service",
15
+ "name": "GSMA Mobile World Congress",
16
+ "id": "177607143648"
17
+ }, {
18
+ "category": "Business/economy website",
19
+ "name": "デザイナーズSOHOオフィスなら【SOHO東京】",
20
+ "id": "140108926038346"
21
+ }, {
22
+ "category": "Real estate",
23
+ "category_list": [{
24
+ "id": "198327773511962",
25
+ "name": "Real Estate"
26
+ }],
27
+ "name": "ジョイライフスタイル",
28
+ "id": "117500321741291"
29
+ }, {
30
+ "category": "Internet/software",
31
+ "category_list": [{
32
+ "id": "10101472279007861",
33
+ "name": "Internet/Software"
34
+ }],
35
+ "name": "Engineerrise",
36
+ "id": "565244630160593"
37
+ }, {
38
+ "category": "Electronics",
39
+ "name": "Rapiro",
40
+ "id": "124199987785627"
41
+ }],
42
+ "paging": {
43
+ "next": "https://graph.facebook.com/v2.0/579612276?pretty=1&fields=context.fields(mutual_likes.limit(5).after(MTI0MTk5OTg3Nzg1NjI3))",
44
+ "cursors": {
45
+ "before": "MTc3NjA3MTQzNjQ4",
46
+ "after": "MTI0MTk5OTg3Nzg1NjI3"
47
+ }
48
+ },
49
+ "summary": {
50
+ "total_count": 89
51
+ }
52
+ }
53
+ },
54
+ "currency": {
55
+ "currency_offset": 1,
56
+ "usd_exchange": 0.0097614,
57
+ "usd_exchange_inverse": 102.4443215113,
58
+ "user_currency": "JPY"
59
+ },
60
+ "devices": [{
61
+ "hardware": "iPhone",
62
+ "os": "iOS"
63
+ }],
64
+ "id": "579612276"
65
+ }
@@ -0,0 +1,27 @@
1
+ {
2
+ "data": [{
3
+ "id": "AVm6afobc20T0wATmCYRk_CNymo_44MQW8yMBwpgDFAQ18iF9feZpDEDmwfmcjSBSSuYkFfD5fx77g_uJRF0fmQ7AR2kObX8biP4wzN7UMpbYQ",
4
+ "name": "Shingo Yamanaka",
5
+ "picture": {
6
+ "data": {
7
+ "is_silhouette": false,
8
+ "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xpf1/t1.0-1/c0.15.85.85/s50x50/1468668_10152037195781416_2050550170_s.jpg"
9
+ }
10
+ }
11
+ }, {
12
+ "id": "AVnJiIlmAtrWJ106ErRPlLZNy8_Hd4mfmuQBrbGm4tuFS_ENvyYdVxTwgesXE5Wp2ICtxcPHzkA4Y4BJAWwJqyUie2ZDKQeKn9mnjPCVAUr8Lg",
13
+ "name": "Hayashi Tatsuya",
14
+ "picture": {
15
+ "data": {
16
+ "is_silhouette": false,
17
+ "url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xaf1/t1.0-1/c79.38.479.479/s50x50/388771_10150501378984825_523522119_n.jpg"
18
+ }
19
+ }
20
+ }],
21
+ "paging": {
22
+ "cursors": {
23
+ "before": "QVZra09GaExkNndsM1J5eVpuQ2dWS1hLV3FBb0dqRTh3dC1PVXJIZE8ya0JzbV9kUDZXcWZEdUtUZFNHejcxeGlWZ3JjZjZjdkIwMWdtSWtHZGpGVE8wTWZ5cUdNUm5NWWw3c2hSTEtPZ19ySmc=",
24
+ "after": "QVZrdlNsUHItNExPY1JIUVdlZ3BDZlFCTHFFMUl6YVhnVG5fRVlBLVV0QThUMFBmRnZNQkVQWVg2VkRBQWhRa3RyemVQUFhscWxBVERYZU15SExZbG50Z0RTQUtfVno5VjRjT3VUb2J5NGg1VFE="
25
+ }
26
+ }
27
+ }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nov matake
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-13 00:00:00.000000000 Z
11
+ date: 2014-08-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httpclient
@@ -221,6 +221,7 @@ files:
221
221
  - lib/fb_graph2/edge/static_resources.rb
222
222
  - lib/fb_graph2/edge/statuses.rb
223
223
  - lib/fb_graph2/edge/subscriptions.rb
224
+ - lib/fb_graph2/edge/taggable_friends.rb
224
225
  - lib/fb_graph2/edge/tagged.rb
225
226
  - lib/fb_graph2/edge/tagged_places.rb
226
227
  - lib/fb_graph2/edge/tags.rb
@@ -258,9 +259,9 @@ files:
258
259
  - lib/fb_graph2/struct/currency.rb
259
260
  - lib/fb_graph2/struct/device.rb
260
261
  - lib/fb_graph2/struct/education.rb
262
+ - lib/fb_graph2/struct/friend.rb
261
263
  - lib/fb_graph2/struct/group_file.rb
262
264
  - lib/fb_graph2/struct/image_source.rb
263
- - lib/fb_graph2/struct/invitable_friend.rb
264
265
  - lib/fb_graph2/struct/location.rb
265
266
  - lib/fb_graph2/struct/parking.rb
266
267
  - lib/fb_graph2/struct/payment_options.rb
@@ -316,6 +317,7 @@ files:
316
317
  - spec/fb_graph2/edge/shared_posts_spec.rb
317
318
  - spec/fb_graph2/edge/statuses_spec.rb
318
319
  - spec/fb_graph2/edge/subscriptions_spec.rb
320
+ - spec/fb_graph2/edge/taggable_friends_spec.rb
319
321
  - spec/fb_graph2/edge/television_spec.rb
320
322
  - spec/fb_graph2/edge/test_users_spec.rb
321
323
  - spec/fb_graph2/edge/videos_spec.rb
@@ -360,6 +362,7 @@ files:
360
362
  - spec/mock_json/user/likes.json
361
363
  - spec/mock_json/user/links.json
362
364
  - spec/mock_json/user/me.json
365
+ - spec/mock_json/user/me_with_ext_attrs.json
363
366
  - spec/mock_json/user/movies.json
364
367
  - spec/mock_json/user/music.json
365
368
  - spec/mock_json/user/notifications.json
@@ -370,6 +373,7 @@ files:
370
373
  - spec/mock_json/user/posts.json
371
374
  - spec/mock_json/user/scores.json
372
375
  - spec/mock_json/user/statuses.json
376
+ - spec/mock_json/user/taggable_friends.json
373
377
  - spec/mock_json/user/television.json
374
378
  - spec/mock_json/user/videos.json
375
379
  - spec/spec_helper.rb
@@ -1,10 +0,0 @@
1
- module FbGraph2
2
- class Struct
3
- class InvitableFriend < Struct
4
- register_attributes(
5
- raw: [:id, :name],
6
- picture: [:picture]
7
- )
8
- end
9
- end
10
- end