added hidden schedule api

This commit is contained in:
Mariotaku Lee 2015-07-06 23:04:25 +08:00
parent 9cd4dbbc4c
commit 29a5de17e5
9 changed files with 207 additions and 5 deletions

View File

@ -28,6 +28,7 @@ import org.mariotaku.twidere.api.twitter.api.PlacesGeoResources;
import org.mariotaku.twidere.api.twitter.api.PrivateActivityResources;
import org.mariotaku.twidere.api.twitter.api.PrivateDirectMessagesResources;
import org.mariotaku.twidere.api.twitter.api.PrivateFriendsFollowersResources;
import org.mariotaku.twidere.api.twitter.api.PrivateScheduleResources;
import org.mariotaku.twidere.api.twitter.api.PrivateTimelinesResources;
import org.mariotaku.twidere.api.twitter.api.PrivateTweetResources;
import org.mariotaku.twidere.api.twitter.api.SavedSearchesResources;
@ -46,5 +47,5 @@ public interface Twitter extends SearchResource, TimelinesResources,
TweetResources, UsersResources, ListsResources, DirectMessagesResources, FriendsFollowersResources,
FavoritesResources, SpamReportingResources, SavedSearchesResources, TrendsResources, PlacesGeoResources,
HelpResources, PrivateActivityResources, PrivateTweetResources, PrivateTimelinesResources,
PrivateFriendsFollowersResources, PrivateDirectMessagesResources {
PrivateFriendsFollowersResources, PrivateDirectMessagesResources, PrivateScheduleResources {
}

View File

@ -0,0 +1,48 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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/>.
*/
package org.mariotaku.twidere.api.twitter.api;
import org.mariotaku.restfu.annotation.method.DELETE;
import org.mariotaku.restfu.annotation.method.POST;
import org.mariotaku.restfu.annotation.method.PUT;
import org.mariotaku.restfu.annotation.param.Body;
import org.mariotaku.restfu.annotation.param.Form;
import org.mariotaku.restfu.annotation.param.Path;
import org.mariotaku.restfu.http.BodyType;
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
import org.mariotaku.twidere.api.twitter.model.StatusSchedule;
/**
* Created by mariotaku on 15/7/6.
*/
public interface PrivateScheduleResources {
@POST("/schedule/status/tweet.json")
@Body(BodyType.FORM)
ScheduledStatus scheduleTweet(@Form StatusSchedule schedule);
@DELETE("/schedule/status/{id}.json")
ScheduledStatus destroyScheduleTweet(@Path("id") long id);
@PUT("/schedule/status/{id}.json")
@Body(BodyType.FORM)
ScheduledStatus updateScheduleTweet(@Path("id") long id, @Form StatusSchedule schedule);
}

View File

@ -0,0 +1,38 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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/>.
*/
package org.mariotaku.twidere.api.twitter.model;
import java.util.Date;
/**
* Created by mariotaku on 15/7/6.
*/
public interface ScheduledStatus {
long[] getMediaIds();
Date getUpdatedAt();
Date getCreatedAt();
Date getExecuteAt();
String getText();
}

View File

@ -0,0 +1,36 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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/>.
*/
package org.mariotaku.twidere.api.twitter.model;
import java.util.Date;
import java.util.concurrent.TimeUnit;
/**
* Created by mariotaku on 15/7/6.
*/
public class StatusSchedule extends StatusUpdate {
public StatusSchedule(String status) {
super(status);
}
public void setExecuteAt(Date executeAt) {
put("execute_at", TimeUnit.SECONDS.convert(executeAt.getTime(), TimeUnit.MILLISECONDS));
}
}

View File

@ -22,7 +22,7 @@ package org.mariotaku.twidere.api.twitter.model;
import org.mariotaku.restfu.Utils;
import org.mariotaku.restfu.http.SimpleValueMap;
public final class StatusUpdate extends SimpleValueMap {
public class StatusUpdate extends SimpleValueMap {
public StatusUpdate(final String status) {
put("status", status);

View File

@ -0,0 +1,71 @@
/*
* Twidere - Twitter client for Android
*
* Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
*
* 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/>.
*/
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.ScheduledStatus;
import org.mariotaku.twidere.api.twitter.util.TwitterDateConverter;
import java.util.Date;
/**
* Created by mariotaku on 15/7/6.
*/
@JsonObject
public class ScheduledStatusImpl implements ScheduledStatus {
@JsonField(name = "updated_at", typeConverter = TwitterDateConverter.class)
Date updatedAt;
@JsonField(name = "created_at", typeConverter = TwitterDateConverter.class)
Date createdAt;
@JsonField(name = "execute_at", typeConverter = TwitterDateConverter.class)
Date executeAt;
@JsonField(name = "text")
String text;
@JsonField(name = "media_ids")
long[] mediaIds;
@Override
public long[] getMediaIds() {
return mediaIds;
}
@Override
public Date getUpdatedAt() {
return updatedAt;
}
@Override
public Date getCreatedAt() {
return createdAt;
}
@Override
public Date getExecuteAt() {
return executeAt;
}
@Override
public String getText() {
return text;
}
}

View File

@ -51,6 +51,7 @@ import org.mariotaku.twidere.api.twitter.model.Relationship;
import org.mariotaku.twidere.api.twitter.model.ResponseCode;
import org.mariotaku.twidere.api.twitter.model.ResponseList;
import org.mariotaku.twidere.api.twitter.model.SavedSearch;
import org.mariotaku.twidere.api.twitter.model.ScheduledStatus;
import org.mariotaku.twidere.api.twitter.model.Status;
import org.mariotaku.twidere.api.twitter.model.StatusActivitySummary;
import org.mariotaku.twidere.api.twitter.model.StatusDeletionNotice;
@ -82,6 +83,7 @@ import org.mariotaku.twidere.api.twitter.model.impl.RelationshipImpl;
import org.mariotaku.twidere.api.twitter.model.impl.RelationshipWrapper;
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.ScheduledStatusImpl;
import org.mariotaku.twidere.api.twitter.model.impl.StatusActivitySummaryImpl;
import org.mariotaku.twidere.api.twitter.model.impl.StatusDeletionNoticeImpl;
import org.mariotaku.twidere.api.twitter.model.impl.StatusImpl;
@ -152,6 +154,7 @@ public class TwitterConverter implements Converter {
TypeConverterMapper.register(Activity.class, ActivityImpl.class, ActivityImpl.MAPPER);
TypeConverterMapper.register(Warning.class, WarningImpl.class);
TypeConverterMapper.register(StatusDeletionNotice.class, StatusDeletionNoticeImpl.class);
TypeConverterMapper.register(ScheduledStatus.class, ScheduledStatusImpl.class);
LoganSquare.registerTypeConverter(Indices.class, Indices.CONVERTER);
LoganSquare.registerTypeConverter(GeoLocation.class, GeoLocation.CONVERTER);

View File

@ -26,7 +26,7 @@ import android.support.annotation.NonNull;
*/
public enum ConsumerKeyType {
TWITTER_FOR_ANDROID, TWITTER_FOR_IPHONE, TWITTER_FOR_IPAD, TWITTER_FOR_MAC,
TWITTER_FOR_WINDOWS_PHONE, TWITTER_FOR_GOOGLE_TV, UNKNOWN;
TWITTER_FOR_WINDOWS_PHONE, TWITTER_FOR_GOOGLE_TV, TWEETDECK, UNKNOWN;
@NonNull
public static ConsumerKeyType parse(String type) {

View File

@ -1,5 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
<?xml version="1.0" encoding="utf-8"?><!--
~ Twidere - Twitter client for Android
~
~ Copyright (C) 2012-2015 Mariotaku Lee <mariotaku.lee@gmail.com>
@ -33,6 +32,8 @@
<item>62bd0d33</item>
<!--Twitter for Google TV-->
<item>56d8f9ff</item>
<!--TweetDeck-->
<item>ac602936</item>
</string-array>
<string-array name="names_official_consumer_secret">
<!--Twitter for Android-->
@ -47,6 +48,8 @@
<item>Twitter for Windows Phone</item>
<!--Twitter for Google TV-->
<item>Twitter for Google TV</item>
<!--TweetDeck-->
<item>TweetDeck</item>
</string-array>
<string-array name="types_official_consumer_secret">
<!--Twitter for Android-->
@ -61,5 +64,7 @@
<item>TWITTER_FOR_WINDOWS_PHONE</item>
<!--Twitter for Google TV-->
<item>TWITTER_FOR_GOOGLE_TV</item>
<!--TweetDeck-->
<item>TWEETDECK</item>
</string-array>
</resources>