From 57cf2e7eff36ee51b1aeda263a2280589fbea5dd Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 13 May 2015 22:00:31 +0800 Subject: [PATCH] implemented some apis --- .../api/twitter/api/ListsResources.java | 34 +++++---- .../api/twitter/model/AccountSettings.java | 26 ------- .../twidere/api/twitter/model/TimeZone.java | 10 ++- .../model/impl/AccountSettingsImpl.java | 71 +++++++++++++++++++ .../api/twitter/model/impl/TimeZoneImpl.java | 54 ++++++++++++++ .../api/twitter/util/TwitterConverter.java | 6 ++ 6 files changed, 157 insertions(+), 44 deletions(-) create mode 100644 twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/AccountSettingsImpl.java create mode 100644 twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/TimeZoneImpl.java diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/ListsResources.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/ListsResources.java index f30189604..e53feba3b 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/ListsResources.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/api/ListsResources.java @@ -25,19 +25,15 @@ import org.mariotaku.simplerestapi.method.POST; import org.mariotaku.simplerestapi.param.Body; import org.mariotaku.simplerestapi.param.Form; import org.mariotaku.simplerestapi.param.Query; - +import org.mariotaku.twidere.api.twitter.TwitterException; import org.mariotaku.twidere.api.twitter.model.PageableResponseList; import org.mariotaku.twidere.api.twitter.model.Paging; import org.mariotaku.twidere.api.twitter.model.ResponseList; import org.mariotaku.twidere.api.twitter.model.Status; -import org.mariotaku.twidere.api.twitter.TwitterException; import org.mariotaku.twidere.api.twitter.model.User; import org.mariotaku.twidere.api.twitter.model.UserList; import org.mariotaku.twidere.api.twitter.model.UserListUpdate; -/** - * @author Joern Huxhorn - jhuxhorn at googlemail.com - */ @SuppressWarnings("RedundantThrows") public interface ListsResources { @POST("/lists/members/create.json") @@ -60,19 +56,33 @@ public interface ListsResources { @Body(BodyType.FORM) UserList createUserList(@Form UserListUpdate update) throws TwitterException; - UserList createUserListSubscription(@Query("list_id") long listId) throws TwitterException; + @POST("/lists/subscribers/create.json") + @Body(BodyType.FORM) + UserList createUserListSubscription(@Form("list_id") long listId) throws TwitterException; + @POST("/lists/members/destroy.json") + @Body(BodyType.FORM) UserList deleteUserListMember(@Query("list_id") long listId, @Query("user_id") long userId) throws TwitterException; - UserList deleteUserListMember(@Query("list_id") long listId, String screenName) throws TwitterException; + @POST("/lists/members/destroy.json") + @Body(BodyType.FORM) + UserList deleteUserListMember(@Query("list_id") long listId, @Form("screen_name") String screenName) throws TwitterException; - UserList deleteUserListMembers(@Query("list_id") long listId, long[] userIds) throws TwitterException; + @POST("/lists/members/destroy_all.json") + @Body(BodyType.FORM) + UserList deleteUserListMembers(@Form("list_id") long listId, @Form("user_id") long[] userIds) throws TwitterException; - UserList deleteUserListMembers(@Query("list_id") long listId, String[] screenNames) throws TwitterException; + @POST("/lists/members/destroy_all.json") + @Body(BodyType.FORM) + UserList deleteUserListMembers(@Query("list_id") long listId, @Form("screen_name") String[] screenNames) throws TwitterException; - UserList destroyUserList(@Query("list_id") long listId) throws TwitterException; + @POST("/lists/destroy.json") + @Body(BodyType.FORM) + UserList destroyUserList(@Form("list_id") long listId) throws TwitterException; - UserList destroyUserListSubscription(@Query("list_id") long listId) throws TwitterException; + @POST("/lists/subscribers/destroy.json") + @Body(BodyType.FORM) + UserList destroyUserListSubscription(@Form("list_id") long listId) throws TwitterException; @GET("/lists/members.json") PageableResponseList getUserListMembers(@Query("list_id") long listId, @Query Paging paging) throws TwitterException; @@ -160,5 +170,5 @@ public interface ListsResources { @POST("/lists/update.json") @Body(BodyType.FORM) - UserList updateUserList(@Query("list_id") long listId, @Form UserListUpdate update) throws TwitterException; + UserList updateUserList(@Form("list_id") long listId, @Form UserListUpdate update) throws TwitterException; } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/AccountSettings.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/AccountSettings.java index 22dd4d7c6..7ca49b2e2 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/AccountSettings.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/AccountSettings.java @@ -31,20 +31,6 @@ public interface AccountSettings extends TwitterResponse { */ String getLanguage(); - /** - * Returns sleep end time. - * - * @return sleep end time - */ - String getSleepEndTime(); - - /** - * Returns sleep start time. - * - * @return sleep start time - */ - String getSleepStartTime(); - /** * Returns the timezone configured for this user. * @@ -66,12 +52,6 @@ public interface AccountSettings extends TwitterResponse { */ boolean isAlwaysUseHttps(); - /** - * Returns true if the user is discoverable by email. - * - * @return true if the user is discoverable by email - */ - boolean isDiscoverableByEmail(); /** * Return true if the user is enabling geo location @@ -80,10 +60,4 @@ public interface AccountSettings extends TwitterResponse { */ boolean isGeoEnabled(); - /** - * Returns true if the user enabled sleep time. - * - * @return true if the user enabled sleep time - */ - boolean isSleepTimeEnabled(); } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/TimeZone.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/TimeZone.java index ff26fe6bb..01bebb0e2 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/TimeZone.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/TimeZone.java @@ -19,15 +19,13 @@ package org.mariotaku.twidere.api.twitter.model; -import java.io.Serializable; - /** * @author Alessandro Bahgat - ale.bahgat at gmail.com */ -public interface TimeZone extends Serializable { - String getName(); +public interface TimeZone { + String getName(); - String tzinfoName(); + String getTzInfoName(); - int utcOffset(); + int getUtcOffset(); } diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/AccountSettingsImpl.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/AccountSettingsImpl.java new file mode 100644 index 000000000..885ba7d73 --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/AccountSettingsImpl.java @@ -0,0 +1,71 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.api.twitter.model.impl; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; + +import org.mariotaku.twidere.api.twitter.model.AccountSettings; +import org.mariotaku.twidere.api.twitter.model.Location; +import org.mariotaku.twidere.api.twitter.model.TimeZone; + +/** + * Created by mariotaku on 15/5/13. + */ +@JsonObject +public class AccountSettingsImpl extends TwitterResponseImpl implements AccountSettings { + + @JsonField(name = "geo_enabled") + boolean geoEnabled; + @JsonField(name = "trend_location") + Location[] trendLocations; + @JsonField(name = "language") + String language; + @JsonField(name = "always_use_https") + boolean alwaysUseHttps; + @JsonField(name = "time_zone") + TimeZone timezone; + + @Override + public boolean isAlwaysUseHttps() { + return alwaysUseHttps; + } + + @Override + public String getLanguage() { + return language; + } + + @Override + public TimeZone getTimeZone() { + return timezone; + } + + @Override + public Location[] getTrendLocations() { + return trendLocations; + } + + @Override + public boolean isGeoEnabled() { + return geoEnabled; + } + +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/TimeZoneImpl.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/TimeZoneImpl.java new file mode 100644 index 000000000..83d60b312 --- /dev/null +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/model/impl/TimeZoneImpl.java @@ -0,0 +1,54 @@ +/* + * Twidere - Twitter client for Android + * + * Copyright (C) 2012-2015 Mariotaku Lee + * + * 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 . + */ + +package org.mariotaku.twidere.api.twitter.model.impl; + +import com.bluelinelabs.logansquare.annotation.JsonField; +import com.bluelinelabs.logansquare.annotation.JsonObject; + +import org.mariotaku.twidere.api.twitter.model.TimeZone; + +/** + * Created by mariotaku on 15/5/13. + */ +@JsonObject +public class TimeZoneImpl implements TimeZone { + + @JsonField(name = "utc_offset") + int utcOffset; + @JsonField(name = "name") + String name; + @JsonField(name = "tzinfo_name") + String tzInfoName; + + @Override + public int getUtcOffset() { + return utcOffset; + } + + @Override + public String getName() { + return name; + } + + @Override + public String getTzInfoName() { + return tzInfoName; + } +} diff --git a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/util/TwitterConverter.java b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/util/TwitterConverter.java index 5a7f6a036..8c912f234 100644 --- a/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/util/TwitterConverter.java +++ b/twidere.component.common/src/main/java/org/mariotaku/twidere/api/twitter/util/TwitterConverter.java @@ -32,6 +32,7 @@ import org.mariotaku.simplerestapi.http.RestHttpResponse; import org.mariotaku.simplerestapi.http.mime.TypedData; import org.mariotaku.twidere.api.twitter.TwitterException; import org.mariotaku.twidere.api.twitter.auth.OAuthToken; +import org.mariotaku.twidere.api.twitter.model.AccountSettings; import org.mariotaku.twidere.api.twitter.model.Activity; import org.mariotaku.twidere.api.twitter.model.CardEntity; import org.mariotaku.twidere.api.twitter.model.DirectMessage; @@ -51,6 +52,7 @@ import org.mariotaku.twidere.api.twitter.model.ResponseList; import org.mariotaku.twidere.api.twitter.model.SavedSearch; import org.mariotaku.twidere.api.twitter.model.Status; import org.mariotaku.twidere.api.twitter.model.StatusActivitySummary; +import org.mariotaku.twidere.api.twitter.model.TimeZone; import org.mariotaku.twidere.api.twitter.model.TranslationResult; import org.mariotaku.twidere.api.twitter.model.Trend; import org.mariotaku.twidere.api.twitter.model.Trends; @@ -58,6 +60,7 @@ import org.mariotaku.twidere.api.twitter.model.UrlEntity; import org.mariotaku.twidere.api.twitter.model.User; import org.mariotaku.twidere.api.twitter.model.UserList; import org.mariotaku.twidere.api.twitter.model.UserMentionEntity; +import org.mariotaku.twidere.api.twitter.model.impl.AccountSettingsImpl; import org.mariotaku.twidere.api.twitter.model.impl.ActivityImpl; import org.mariotaku.twidere.api.twitter.model.impl.CardEntityImpl; import org.mariotaku.twidere.api.twitter.model.impl.DirectMessageImpl; @@ -78,6 +81,7 @@ import org.mariotaku.twidere.api.twitter.model.impl.ResponseListImpl; import org.mariotaku.twidere.api.twitter.model.impl.SavedSearchImpl; import org.mariotaku.twidere.api.twitter.model.impl.StatusActivitySummaryImpl; import org.mariotaku.twidere.api.twitter.model.impl.StatusImpl; +import org.mariotaku.twidere.api.twitter.model.impl.TimeZoneImpl; import org.mariotaku.twidere.api.twitter.model.impl.TranslationResultImpl; import org.mariotaku.twidere.api.twitter.model.impl.TrendImpl; import org.mariotaku.twidere.api.twitter.model.impl.TrendsImpl; @@ -137,6 +141,8 @@ public class TwitterConverter implements Converter { TypeConverterMapper.register(Location.class, LocationImpl.class); TypeConverterMapper.register(Location.PlaceType.class, LocationImpl.PlaceTypeImpl.class); TypeConverterMapper.register(StatusActivitySummary.class, StatusActivitySummaryImpl.class); + TypeConverterMapper.register(TimeZone.class, TimeZoneImpl.class); + TypeConverterMapper.register(AccountSettings.class, AccountSettingsImpl.class); TypeConverterMapper.register(IDs.class, IDsImpl.class, IDsImpl.MAPPER); TypeConverterMapper.register(Activity.class, ActivityImpl.class, ActivityImpl.MAPPER);