OSDN Git Service

2019/5/20に予定されているTwitter APIの仕様変更に対応
authorKimura Youichi <kim.upsilon@bucyou.net>
Sat, 20 Apr 2019 23:26:51 +0000 (08:26 +0900)
committerKimura Youichi <kim.upsilon@bucyou.net>
Sat, 20 Apr 2019 23:26:51 +0000 (08:26 +0900)
OpenTween.Tests/Api/DataModel/TwitterUser_20190520ChangesTest.cs [new file with mode: 0644]
OpenTween/Api/DataModel/TwitterUser.cs
OpenTween/Resources/ChangeLog.txt

diff --git a/OpenTween.Tests/Api/DataModel/TwitterUser_20190520ChangesTest.cs b/OpenTween.Tests/Api/DataModel/TwitterUser_20190520ChangesTest.cs
new file mode 100644 (file)
index 0000000..e4a99d9
--- /dev/null
@@ -0,0 +1,84 @@
+// OpenTween - Client of Twitter
+// Copyright (c) 2019 kim_upsilon (@kim_upsilon) <https://upsilo.net/~upsilon/>
+// All rights reserved.
+//
+// This file is part of OpenTween.
+//
+// This program is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by the Free
+// Software Foundation; either version 3 of the License, or (at your option)
+// any later version.
+//
+// This program is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+// or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+// for more details.
+//
+// You should have received a copy of the GNU General Public License along
+// with this program. If not, see <http://www.gnu.org/licenses/>, or write to
+// the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
+// Boston, MA 02110-1301, USA.
+
+using Xunit;
+
+namespace OpenTween.Api.DataModel
+{
+    public class TwitterUser_20190520ChangesTest
+    {
+        [Fact]
+        public void ParseJsonTest()
+        {
+            // 2019-05-20 に予定されている User object の仕様変更テスト
+            //  (廃止されるフィールドに null がセットされる)
+            // https://twittercommunity.com/t/124732
+
+            var json = @"{
+    ""id"": 6253282,
+    ""id_str"": ""6253282"",
+    ""name"": ""Twitter API"",
+    ""screen_name"": ""TwitterAPI"",
+    ""location"": ""San Francisco, CA"",
+    ""profile_location"": null,
+    ""description"": ""The Real Twitter API. Tweets about API changes, service issues and our Developer Platform. Don't get an answer? It's on my website."",
+    ""url"": ""https:\/\/t.co\/8IkCzCDr19"",
+    ""protected"": false,
+    ""followers_count"": 6133601,
+    ""friends_count"": 12,
+    ""listed_count"": 12935,
+    ""created_at"": ""Wed May 23 06:01:13 +0000 2007"",
+    ""favourites_count"": 31,
+    ""utc_offset"": null,
+    ""time_zone"": null,
+    ""geo_enabled"": null,
+    ""verified"": true,
+    ""statuses_count"": 3657,
+    ""lang"": null,
+    ""contributors_enabled"": null,
+    ""is_translator"": null,
+    ""is_translation_enabled"": null,
+    ""profile_background_color"": null,
+    ""profile_background_image_url"": null,
+    ""profile_background_image_url_https"": null,
+    ""profile_background_tile"": null,
+    ""profile_image_url"": null,
+    ""profile_image_url_https"": ""https:\/\/pbs.twimg.com\/profile_images\/942858479592554497\/BbazLO9L_normal.jpg"",
+    ""profile_banner_url"": ""https:\/\/pbs.twimg.com\/profile_banners\/6253282\/1497491515"",
+    ""profile_image_extensions_alt_text"": null,
+    ""profile_banner_extensions_alt_text"": null,
+    ""profile_link_color"": null,
+    ""profile_sidebar_border_color"": null,
+    ""profile_sidebar_fill_color"": null,
+    ""profile_text_color"": null,
+    ""profile_use_background_image"": null,
+    ""has_extended_profile"": null,
+    ""default_profile"": false,
+    ""default_profile_image"": false,
+    ""following"": null,
+    ""follow_request_sent"": null,
+    ""notifications"": null,
+    ""translator_type"": null
+}";
+            TwitterUser.ParseJson(json);
+        }
+    }
+}
index 2e31933..78a0449 100644 (file)
@@ -34,9 +34,6 @@ namespace OpenTween.Api.DataModel
     [DataContract]
     public class TwitterUser
     {
-        [DataMember(Name = "contributors_enabled")]
-        public bool ContributorsEnabled { get; set; }
-
         [DataMember(Name = "created_at")]
         public string CreatedAt { get; set; }
 
@@ -65,27 +62,18 @@ namespace OpenTween.Api.DataModel
         [DataMember(Name = "favourites_count")]
         public int FavouritesCount { get; set; }
 
-        [DataMember(Name = "follow_request_sent")]
-        public bool? FollowRequestSent { get; set; }
-
         [DataMember(Name = "followers_count")]
         public int FollowersCount { get; set; }
 
         [DataMember(Name = "friends_count")]
         public int FriendsCount { get; set; }
 
-        [DataMember(Name = "geo_enabled")]
-        public bool GeoEnabled { get; set; }
-
         [DataMember(Name = "id")]
         public long Id { get; set; }
 
         [DataMember(Name = "id_str")]
         public string IdStr { get; set; }
 
-        [DataMember(Name = "lang")]
-        public string Lang { get; set; }
-
         [DataMember(Name = "listed_count")]
         public int? ListedCount { get; set; }
 
@@ -95,36 +83,12 @@ namespace OpenTween.Api.DataModel
         [DataMember(Name = "name")]
         public string Name { get; set; }
 
-        [DataMember(Name = "profile_background_color")]
-        public string ProfileBackgroundColor { get; set; }
-
-        [DataMember(Name = "profile_background_image_url_https")]
-        public string ProfileBackgroundImageUrlHttps { get; set; }
-
-        [DataMember(Name = "profile_background_tile")]
-        public bool ProfileBackgroundTile { get; set; }
-
         [DataMember(Name = "profile_banner_url")]
         public string ProfileBannerUrl { get; set; }
 
         [DataMember(Name = "profile_image_url_https")]
         public string ProfileImageUrlHttps { get; set; }
 
-        [DataMember(Name = "profile_link_color")]
-        public string ProfileLinkColor { get; set; }
-
-        [DataMember(Name = "profile_sidebar_border_color")]
-        public string ProfileSidebarBorderColor { get; set; }
-
-        [DataMember(Name = "profile_sidebar_fill_color")]
-        public string ProfileSidebarFillColor { get; set; }
-
-        [DataMember(Name = "profile_text_color")]
-        public string ProfileTextColor { get; set; }
-
-        [DataMember(Name = "profile_use_background_image")]
-        public bool ProfileUseBackgroundImage { get; set; }
-
         [DataMember(Name = "protected")]
         public bool Protected { get; set; }
 
@@ -143,9 +107,6 @@ namespace OpenTween.Api.DataModel
         [DataMember(Name = "url")]
         public string Url { get; set; } // Nullable
 
-        [DataMember(Name = "utc_offset")]
-        public int? UtcOffset { get; set; }
-
         [DataMember(Name = "verified")]
         public bool Verified { get; set; }
 
index d39d2eb..3a8abd6 100644 (file)
@@ -1,6 +1,8 @@
 更新履歴
 
 ==== Ver 2.3.1-dev(2019/xx/xx)
+ * FIX: 2019/5/20に予定されているTwitter APIの仕様変更によりエラーが発生する問題を修正
+  - OpenTween v2.3.0 までのバージョンは2019/5/20以降に使用できなくなる可能性があります
 
 ==== Ver 2.3.0(2019/04/08)
  * CHG: 投稿欄にフォーカスしている間は一部のショートカットを無効にします (thx @pitermach, @lukaszgo1!)