From 4a49e6faa85fd5acfa030a59facf7a0d155b98c4 Mon Sep 17 00:00:00 2001 From: Nitish Madhukar Date: Thu, 9 Feb 2017 06:39:20 -0500 Subject: [PATCH] Update v2.8 (#1) * default v2.4 * links edge is no longer available. use feed https://developers.facebook.com/docs/apps/changelog#v2_4_changes * statuses edge is no longer available. use feed https://developers.facebook.com/docs/apps/changelog#v2_4_changes * invited edge is no longer available https://developers.facebook.com/docs/apps/changelog#v2_4_changes * home edge is no longer available. https://developers.facebook.com/docs/apps/changelog#v2_4_changes * inbox edge is no longer available. https://developers.facebook.com/docs/apps/changelog#v2_4_changes * notifications and outbox edges are no longer availabe. https://developers.facebook.com/docs/apps/changelog#v2_4_changes ps. outbox isn't mentioned in the doc, but read_mailbox deprecation causes outbox deprecation too. * update graph api version to 2.8 * update gem version * remove applications edge * update message_tags json data format * align with features in v2.8 * align with features in v2.7 * align with features in v2.6 * align with features in v2.5 * align with features in v2.4 --- VERSION | 2 +- lib/fb_graph2.rb | 2 +- lib/fb_graph2/app.rb | 1 - lib/fb_graph2/edge/applications.rb | 12 ------ lib/fb_graph2/edge/open_graph/actions.rb | 19 --------- lib/fb_graph2/edge/open_graph/objects.rb | 12 ------ lib/fb_graph2/event.rb | 2 +- lib/fb_graph2/open_graph/action.rb | 24 ----------- lib/fb_graph2/open_graph/object.rb | 9 ----- lib/fb_graph2/page.rb | 4 +- lib/fb_graph2/post.rb | 7 +--- lib/fb_graph2/user.rb | 4 +- spec/fb_graph2/edge/applications_spec.rb | 20 --------- spec/fb_graph2_spec.rb | 2 +- spec/mock_json/page/promotable_posts.json | 6 +-- spec/mock_json/post/shared_posts.json | 6 +-- spec/mock_json/user/applications.json | 16 -------- spec/mock_json/user/feed.json | 38 +++++++----------- spec/mock_json/user/me.json | 2 +- spec/mock_json/user/og_actions_likes.json | 49 ----------------------- spec/mock_json/user/posts.json | 6 +-- 21 files changed, 30 insertions(+), 213 deletions(-) delete mode 100644 lib/fb_graph2/edge/applications.rb delete mode 100644 lib/fb_graph2/edge/open_graph/actions.rb delete mode 100644 lib/fb_graph2/edge/open_graph/objects.rb delete mode 100644 lib/fb_graph2/open_graph/action.rb delete mode 100644 lib/fb_graph2/open_graph/object.rb delete mode 100644 spec/fb_graph2/edge/applications_spec.rb delete mode 100644 spec/mock_json/user/applications.json delete mode 100644 spec/mock_json/user/og_actions_likes.json diff --git a/VERSION b/VERSION index 8adc70f..899f24f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.8.0 \ No newline at end of file +0.9.0 \ No newline at end of file diff --git a/lib/fb_graph2.rb b/lib/fb_graph2.rb index 0ede856..82f7c82 100644 --- a/lib/fb_graph2.rb +++ b/lib/fb_graph2.rb @@ -8,7 +8,7 @@ module FbGraph2 mattr_accessor :root_url, :api_version, :gem_version, :logger, :debugging, :_http_config_, :object_classes self.root_url = 'https://graph.facebook.com' - self.api_version = 'v2.4' + self.api_version = 'v2.8' self.gem_version = File.read(File.join(__dir__, '../VERSION')).strip self.logger = Logger.new(STDOUT) self.logger.progname = 'FbGraph2' diff --git a/lib/fb_graph2/app.rb b/lib/fb_graph2/app.rb index b020096..12156a0 100644 --- a/lib/fb_graph2/app.rb +++ b/lib/fb_graph2/app.rb @@ -6,7 +6,6 @@ module FbGraph2 include Edge::AppEventTypes include Edge::Banned include Edge::Groups - include Edge::OpenGraph::Objects include Edge::Permissions include Edge::Picture include Edge::Roles::AppContext diff --git a/lib/fb_graph2/edge/applications.rb b/lib/fb_graph2/edge/applications.rb deleted file mode 100644 index dc6ac23..0000000 --- a/lib/fb_graph2/edge/applications.rb +++ /dev/null @@ -1,12 +0,0 @@ -module FbGraph2 - class Edge - module Applications - def applications(params = {}) - apps = self.edge :applications, params, edge_scope: :developer - apps.collect! do |app| - App.new(app[:id], app).authenticate self.access_token - end - end - end - end -end \ No newline at end of file diff --git a/lib/fb_graph2/edge/open_graph/actions.rb b/lib/fb_graph2/edge/open_graph/actions.rb deleted file mode 100644 index 7da39a3..0000000 --- a/lib/fb_graph2/edge/open_graph/actions.rb +++ /dev/null @@ -1,19 +0,0 @@ -module FbGraph2 - class Edge - module OpenGraph - module Actions - def og_actions(action_type, params = {}) - actions = self.edge action_type, params - actions.collect! do |action| - FbGraph2::OpenGraph::Action.new(action[:id], action).authenticate self.access_token - end - end - - def og_action!(action_type, params = {}) - action = self.post params, edge: action_type - FbGraph2::OpenGraph::Action.new(action[:id], params.merge(action)).authenticate self.access_token - end - end - end - end -end \ No newline at end of file diff --git a/lib/fb_graph2/edge/open_graph/objects.rb b/lib/fb_graph2/edge/open_graph/objects.rb deleted file mode 100644 index d9e8684..0000000 --- a/lib/fb_graph2/edge/open_graph/objects.rb +++ /dev/null @@ -1,12 +0,0 @@ -module FbGraph2 - class Edge - module OpenGraph - module Objects - def og_object!(object_type, params = {}) - object = self.post params, edge: :objects, edge_scope: object_type - FbGraph2::OpenGraph::Object.new(object[:id], params.merge(object)).authenticate self.access_token - end - end - end - end -end \ No newline at end of file diff --git a/lib/fb_graph2/event.rb b/lib/fb_graph2/event.rb index c52108d..9f55e8c 100644 --- a/lib/fb_graph2/event.rb +++ b/lib/fb_graph2/event.rb @@ -11,7 +11,7 @@ module FbGraph2 extend Searchable register_attributes( - raw: [:description, :is_date_only, :location, :name, :privacy, :ticket_uri, :timezone], + raw: [:description, :location, :name, :ticket_uri, :timezone], time: [:end_time, :start_time, :updated_time], page: [:venue], profile: [:owner], diff --git a/lib/fb_graph2/open_graph/action.rb b/lib/fb_graph2/open_graph/action.rb deleted file mode 100644 index e0a6c5d..0000000 --- a/lib/fb_graph2/open_graph/action.rb +++ /dev/null @@ -1,24 +0,0 @@ -module FbGraph2 - module OpenGraph - class Action < Node - include Edge::Comments - include Edge::Likes::LikeeContext - - register_attributes( - raw: [:message, :no_feed_story, :ref, :type], - time: [:end_time, :publish_time, :start_time], - app: [:application], - profile: [:from], - custom: [:object] - ) - - def initialize(id, attributes = {}) - super - if attributes.include?(:data) && attributes[:data].include?(:object) - _object_ = attributes[:data][:object] - self.object = OpenGraph::Object.new _object_[:id], _object_ - end - end - end - end -end \ No newline at end of file diff --git a/lib/fb_graph2/open_graph/object.rb b/lib/fb_graph2/open_graph/object.rb deleted file mode 100644 index 1417559..0000000 --- a/lib/fb_graph2/open_graph/object.rb +++ /dev/null @@ -1,9 +0,0 @@ -module FbGraph2 - module OpenGraph - class Object < Node - register_attributes( - raw: [:title, :type, :url] - ) - end - end -end \ No newline at end of file diff --git a/lib/fb_graph2/page.rb b/lib/fb_graph2/page.rb index a761e4e..2685c5b 100644 --- a/lib/fb_graph2/page.rb +++ b/lib/fb_graph2/page.rb @@ -26,9 +26,9 @@ module FbGraph2 raw: [ :about, :attire, :band_members, :booking_agent, :can_post, :category, :checkins, :company_overview, :current_location, :description, :directed_by, :emails, :founded, :general_info, :general_manager, :global_brand_page_name, - :hometown, :hours, :impressum, :is_permanently_closed, :is_published, :is_unclaimed, :likes, :link, :mission, :name, + :hometown, :hours, :impressum, :is_permanently_closed, :is_published, :is_unclaimed, :fan_count, :link, :mission, :name, :name_with_location_descriptor, :phone, :press_contact, :price_range, :products, :talking_about_count, :username, - :website, :were_here_count, + :website, :were_here_count, :is_webhooks_subscribed, # NOTE: only within /:user_id/accounts context :perms ], diff --git a/lib/fb_graph2/post.rb b/lib/fb_graph2/post.rb index b9a94a7..905ddd4 100644 --- a/lib/fb_graph2/post.rb +++ b/lib/fb_graph2/post.rb @@ -24,11 +24,8 @@ module FbGraph2 def initialize(id, attributes = {}) super if attributes.include? :message_tags - self.message_tags = attributes[:message_tags].inject({}) do |message_tags, (key, values)| - _message_tags_ = values.collect do |value| - TaggedProfile.new value[:id], value - end - message_tags.merge! key => _message_tags_ + self.message_tags = attributes[:message_tags].collect do |message_tag| + TaggedProfile.new message_tag[:id], message_tag end end if attributes.include? :privacy diff --git a/lib/fb_graph2/user.rb b/lib/fb_graph2/user.rb index 3fc0abf..364cd10 100644 --- a/lib/fb_graph2/user.rb +++ b/lib/fb_graph2/user.rb @@ -4,7 +4,6 @@ module FbGraph2 include Edge::Achievements include Edge::Activities include Edge::Albums - include Edge::Applications include Edge::AppRequests include Edge::Books include Edge::Domains @@ -36,7 +35,7 @@ module FbGraph2 register_attributes( raw: [ - :about, :bio, :email, :first_name, :gender, :install_type, :installed, :interested_in, :is_eligible_promo, + :about, :email, :first_name, :gender, :install_type, :installed, :interested_in, :is_eligible_promo, :is_shared_login, :is_verified, :last_name, :link, :locale, :meeting_for, :middle_name, :name, :name_format, :political, :quotes, :relationship_status, :religion, :test_group, :third_party_id, :timezone, :token_for_business, :verified, :viewer_can_send_gift, :website, @@ -66,7 +65,6 @@ module FbGraph2 :tagging_user ], photo: [:cover], - location: [:address], custom: [ :age_range, :context, :currency, :devices, :education, :payment_mobile_pricepoints, :payment_pricepoints, :security_settings, :suggested_groups, :video_upload_limits, :work diff --git a/spec/fb_graph2/edge/applications_spec.rb b/spec/fb_graph2/edge/applications_spec.rb deleted file mode 100644 index e503e72..0000000 --- a/spec/fb_graph2/edge/applications_spec.rb +++ /dev/null @@ -1,20 +0,0 @@ -require 'spec_helper' - -describe FbGraph2::Edge::Applications do - context 'included in User' do - let(:me) { FbGraph2::User.me('token') } - - describe '#applications' do - it 'should return an Array of FbGraph2::App' do - apps = mock_graph :get, 'me/applications/developer', 'user/applications', access_token: 'token' do - me.applications - end - apps.should be_instance_of FbGraph2::Edge - apps.should_not be_blank - apps.each do |app| - app.should be_instance_of FbGraph2::App - end - end - end - end -end \ No newline at end of file diff --git a/spec/fb_graph2_spec.rb b/spec/fb_graph2_spec.rb index f77334d..0557f38 100644 --- a/spec/fb_graph2_spec.rb +++ b/spec/fb_graph2_spec.rb @@ -6,7 +6,7 @@ describe FbGraph2 do context 'as default' do its(:logger) { should be_a Logger } - its(:api_version) { should == 'v2.4' } + its(:api_version) { should == 'v2.8' } its(:root_url) { should == 'https://graph.facebook.com' } it { should_not be_debugging } end diff --git a/spec/mock_json/page/promotable_posts.json b/spec/mock_json/page/promotable_posts.json index f59891c..8e9a251 100644 --- a/spec/mock_json/page/promotable_posts.json +++ b/spec/mock_json/page/promotable_posts.json @@ -7,15 +7,13 @@ "id": "140478125968442" }, "story": "OAuth.jp shared a link.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "140478125968442", "name": "OAuth.jp", "offset": 0, "length": 8, "type": "page" - }] - }, + }], "link": "http://oauth.jp/blog/2014/05/09/what-happens-when-oauth2-code-leaked/", "name": "OAuth 2.0 の code は漏れても大丈夫ってホント!? - OAuth.jp", "caption": "oauth.jp", diff --git a/spec/mock_json/post/shared_posts.json b/spec/mock_json/post/shared_posts.json index d57a286..88dd0ea 100644 --- a/spec/mock_json/post/shared_posts.json +++ b/spec/mock_json/post/shared_posts.json @@ -6,15 +6,13 @@ "name": "Shunya Iriki" }, "story": "Shunya Iriki shared a link.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "689134294485152", "name": "Shunya Iriki", "offset": 0, "length": 12, "type": "user" - }] - }, + }], "picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQCtEdPdezKIoUxo&w=154&h=154&url=http%3A%2F%2Fi.yimg.jp%2Fi%2Fdocs%2Frelease%2Ffbicon.jpg", "link": "http://docs.yahoo.co.jp/docs/info/terms/chapter1.html#cf2nd", "name": "ヤフー株式会社 - サービス利用規約 第1編 基本ガイドライン", diff --git a/spec/mock_json/user/applications.json b/spec/mock_json/user/applications.json deleted file mode 100644 index f90d2ae..0000000 --- a/spec/mock_json/user/applications.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "data": [{ - "name": "gem sample", - "namespace": "gem-sample", - "id": "210798282372757" - }, { - "name": "Localhost", - "id": "158245434257042" - }, { - "name": "OAuth.jp", - "id": "126213067419995" - }], - "paging": { - "next": "https://graph.facebook.com/v2.1/579612276/applications?type=developer&limit=25&offset=25&__after_id=***" - } -} diff --git a/spec/mock_json/user/feed.json b/spec/mock_json/user/feed.json index 890e928..c66f1a0 100644 --- a/spec/mock_json/user/feed.json +++ b/spec/mock_json/user/feed.json @@ -6,15 +6,13 @@ "name": "Nov Matake" }, "story": "Nov Matake likes a photo.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "579612276", "name": "Nov Matake", "offset": 0, "length": 10, "type": "user" - }] - }, + }], "privacy": { "value": "" }, @@ -29,22 +27,20 @@ }, "message": "ビッグデータとひわいっち", "story": "Nov Matake shared Keisuke Hiwatashi's photo.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "579612276", "name": "Nov Matake", "offset": 0, "length": 10, "type": "user" - }], - "18": [{ + }, + { "id": "674146975973023", "name": "Keisuke Hiwatashi", "offset": 18, "length": 17, "type": "user" - }] - }, + }], "picture": "https://fbcdn-photos-h-a.akamaihd.net/hphotos-ak-xfp1/t1.0-0/10325169_677983408922713_1895639973177548237_s.jpg", "link": "https://www.facebook.com/photo.php?fbid=677983408922713&set=a.150687431652316.43478.100001331809083&type=1", "name": "Mobile Uploads", @@ -87,15 +83,13 @@ "name": "Nov Matake" }, "story": "Nov Matake shared a link.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "579612276", "name": "Nov Matake", "offset": 0, "length": 10, "type": "user" - }] - }, + }], "picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQAcHDji1ec2KqYZ&w=154&h=154&url=http%3A%2F%2Fua.nakanohito.jp%2Fua%2F%3Ffrom%3Duamb%26id%3D7932754%26mode%3Ddefault%26h%3D55529355%26rand%3Dnoscript%26guid%3DON%26url%3Dhttp%3A%2F%2Fkirik.tea-nifty.com%2Fdiary%2F2014%2F05%2Fivs-ed80.html%26eflg%3D1", "link": "http://ow.ly/xoEJp", "name": "IVS札幌でセクハラ・レイプ未遂騒ぎが勃発&インサイダー情報が乱舞: やまもといちろうBLOG(ブログ)", @@ -152,22 +146,20 @@ }, "message": "じわじわくる", "story": "Nov Matake shared Yoichi Hagiwara's photo.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "579612276", "name": "Nov Matake", "offset": 0, "length": 10, "type": "user" - }], - "18": [{ + }, + { "id": "636860593058872", "name": "Yoichi Hagiwara", "offset": 18, "length": 15, "type": "user" - }] - }, + }], "picture": "https://fbcdn-photos-b-a.akamaihd.net/hphotos-ak-xfp1/t1.0-0/10410479_636298869781711_8967036710690476822_s.jpg", "link": "https://www.facebook.com/photo.php?fbid=636298869781711&set=a.168178316593771.41312.100002048127511&type=1", "name": "Timeline Photos", @@ -209,15 +201,13 @@ "name": "Nov Matake" }, "story": "Nov Matake shared a link.", - "story_tags": { - "0": [{ + "story_tags": [{ "id": "579612276", "name": "Nov Matake", "offset": 0, "length": 10, "type": "user" - }] - }, + }], "picture": "https://fbexternal-a.akamaihd.net/safe_image.php?d=AQDQyx3PnnIPoGqZ&w=154&h=154&url=http%3A%2F%2Fc002.ocn.ne.jp%2Fimg%2Flogo_nttcommunications_001.gif", "link": "http://mypage.ocn.ne.jp/sorry/index.html", "name": "お詫び | マイページ", diff --git a/spec/mock_json/user/me.json b/spec/mock_json/user/me.json index a676d55..37677a6 100644 --- a/spec/mock_json/user/me.json +++ b/spec/mock_json/user/me.json @@ -1,6 +1,6 @@ { "id": "10152411392127277", - "bio": "Ruby/Rails developer, developing several gems like fb_graph, rack-oauth2, paypal-express, openid_connect, activitystreams etc.", + "about": "Ruby/Rails developer, developing several gems like fb_graph, rack-oauth2, paypal-express, openid_connect, activitystreams etc.", "birthday": "12/13/1981", "education": [{ "classes": [{ diff --git a/spec/mock_json/user/og_actions_likes.json b/spec/mock_json/user/og_actions_likes.json deleted file mode 100644 index ddc1d3d..0000000 --- a/spec/mock_json/user/og_actions_likes.json +++ /dev/null @@ -1,49 +0,0 @@ -{ - "data": [ - { - "application": { - "name": "Test Application", - "namespace": "testapp", - "id": "495624957249579" - }, - "comments": { - "data": [ - ], - "can_comment": true, - "comment_order": "chronological", - "count": 0 - }, - "from": { - "id": "0815", - "name": "John Doe" - }, - "likes": { - "data": [ - ], - "can_like": true, - "count": 0, - "user_likes": false - }, - "no_feed_story": false, - "publish_time": "2015-04-06T11:53:54+0000", - "ref": ".hDGIIZ34.like", - "start_time": "2015-04-06T11:53:54+0000", - "type": "og.likes", - "data": { - "object": { - "id": "2893972379237", - "title": "The awesome test site", - "type": "website", - "url": "http://example.com" - } - }, - "id": "4953745973459" - } - ], - "paging": { - "cursors": { - "before": "MTAzsdfsdfzU2OTM5NDYyNQ==", - "after": "NDk2Mz3453czNDergczNzIzNjQw" - } - } -} diff --git a/spec/mock_json/user/posts.json b/spec/mock_json/user/posts.json index 69f84b7..c995fe4 100644 --- a/spec/mock_json/user/posts.json +++ b/spec/mock_json/user/posts.json @@ -12,15 +12,13 @@ }] }, "message": "Nov Matake test", - "message_tags": { - "0": [{ + "message_tags": [{ "id": "579612276", "name": "Nov Matake", "type": "user", "offset": 0, "length": 10 - }] - }, + }], "actions": [{ "name": "Comment", "link": "https://www.facebook.com/579612276/posts/10152483324277277"