-
Notifications
You must be signed in to change notification settings - Fork 65
/
ITwitterClientV1.java
205 lines (180 loc) · 8.89 KB
/
ITwitterClientV1.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
package io.github.redouane59.twitter;
import io.github.redouane59.RelationType;
import io.github.redouane59.twitter.dto.collections.CollectionsResponse;
import io.github.redouane59.twitter.dto.collections.CollectionsResponse.Response.Position;
import io.github.redouane59.twitter.dto.collections.TimeLineOrder;
import io.github.redouane59.twitter.dto.dm.deprecatedV1.DirectMessage;
import io.github.redouane59.twitter.dto.dm.deprecatedV1.DmEvent;
import io.github.redouane59.twitter.dto.others.RateLimitStatus;
import io.github.redouane59.twitter.dto.others.RequestToken;
import io.github.redouane59.twitter.dto.tweet.MediaCategory;
import io.github.redouane59.twitter.dto.tweet.Tweet;
import io.github.redouane59.twitter.dto.tweet.UploadMediaResponse;
import java.io.File;
import java.io.InputStream;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
public interface ITwitterClientV1 {
/**
* Returns a cursored collection of user IDs for every user following the specified user calling https://api.twitter.com/1.1/followers/ids.json
*
* @Deprecated <p> Use {@link ITwitterClientV2#getFollowers(String)} instead.
*/
@Deprecated
List<String> getFollowersIds(String userId);
/**
* Returns a cursored collection of user IDs for every user the specified user is following (otherwise known as their "friends") calling
* https://api.twitter.com/1.1/friends/ids.json
*
* @Deprecated <p> Use {@link ITwitterClientV2#getFollowing(String)} instead.
*/
@Deprecated
List<String> getFollowingIds(String userId);
/**
* Get the relation between two users calling https://api.twitter.com/1.1/friendships/
*
* @param userId1 id of the first user
* @param userId2 id of the second user
* @return One of the following RelationType enum value : FRIENDS if the two users are following each other, NONE if they neither of the two is
* following the other, FOLLOWER if user2 follows user1, FOLLOWING if user1 follows user2
*/
RelationType getRelationType(String userId1, String userId2);
/**
* Get the twitter rate limit status calling https://api.twitter.com/1.1/application/
*
* @return the twitter response
*/
RateLimitStatus getRateLimitStatus();
/**
* Search tweets from last 30 days calling https://api.twitter.com/1.1/tweets/search/30day/dev.json Your development environment name should be
* "dev". See https://developer.twitter.com/en/account/environments
*
* @param query the search query
* @param fromDate the start date
* @param toDate the end date
* @param envName name of the premium environment. See https://developer.twitter.com/en/account/environments
* @return a list of tweets
* @Deprecated <p> Use {@link ITwitterClientV2#searchTweets(String)} instead.
*/
@Deprecated
List<Tweet> searchForTweetsWithin30days(String query, LocalDateTime fromDate, LocalDateTime toDate, String envName);
/**
* Search historic tweets calling https://api.twitter.com/1.1/tweets/search/fullarchive/dev.json Your development environment name should be "dev".
* See https://developer.twitter.com/en/account/environments
*
* @param query the search query
* @param fromDate the start date
* @param toDate the end date
* @param envName name of the premium environment. See https://developer.twitter.com/en/account/environments
* @return a list of tweets
* @Deprecated <p> Use {@link ITwitterClientV2#searchAllTweets(String)} instead.
*/
List<Tweet> searchForTweetsArchive(String query, LocalDateTime fromDate, LocalDateTime toDate, String envName);
/**
* Get token and secret token (oAuth1) calling https://api.twitter.com/oauth/request_token
*
* @return and object containing the oauth token and the oauth token secret
*/
RequestToken getOauth1Token();
/**
* Get token and secret token (oAuth1) calling https://api.twitter.com/oauth/request_token
*
* @param oauthCallback the URL you wish your user to be redirected to when they complete the next step ("oob" to show the pincode)
* @return and object containing the oauth token and the oauth token secret
*/
RequestToken getOauth1Token(String oauthCallback);
/**
* Convert the request token into a usable access token calling https://api.twitter.com/oauth/access_token
*
* @param requestToken the token and secret token
* @param pinCode the oauth verifier
* @return the access tokens
*/
RequestToken getOAuth1AccessToken(RequestToken requestToken, String pinCode);
/**
* Upload a media calling https://upload.twitter.com/1.1/media/upload.json
*/
UploadMediaResponse uploadMedia(String mediaName, byte[] data, MediaCategory mediaCategory);
/**
* Upload a media calling https://upload.twitter.com/1.1/media/upload.json
*/
UploadMediaResponse uploadMedia(File media, MediaCategory mediaCategory);
/**
* Upload a media calling https://upload.twitter.com/1.1/media/upload in chunked mode.
*/
Optional<UploadMediaResponse> uploadChunkedMedia(String mediaName, long size, InputStream data, MediaCategory mediaCategory);
/**
* Upload a media calling https://upload.twitter.com/1.1/media/upload in chunked mode.
*/
Optional<UploadMediaResponse> uploadChunkedMedia(File media, MediaCategory mediaCategory);
/**
* Creates a collection of tweets. See https://api.twitter.com/1.1/collections/create.json
*
* @param name required. Name of the collection - truncated by twitter to 25 characters
* @param description optional. Description for collection - truncated by twitter to 160 characters
* @param collectionUrl optional. A fully-qualified URL to associate with this collection.
* @param timeLineOrder optional. Order Tweets chronologically or in the order they are added to a Collection. Defaults to order tweets added to
* collection ({@link TimeLineOrder#CURATION_ORDER})
* @return CollectionCreateResponse - response from https://api.twitter.com/1.1/collections/create.json - including the collection identifier
* 'timeline_id'
*/
CollectionsResponse collectionsCreate(String name, String description, String collectionUrl, TimeLineOrder timeLineOrder);
/**
* Adds tweets to an existing collection. See https://api.twitter.com/1.1/collections/create.json
*
* @param collectionId the id of the collection to add tweets to
* @param tweetIds Tweets to be added to collection. > 100 will result in multiple calls to the collections/create.json endpoint
* @return an object indicating either no errors or listing the errors for each tweet that was rejected
*/
CollectionsResponse collectionsCurate(String collectionId, List<String> tweetIds);
/**
* Gets tweets from an existing collection. See https://api.twitter.com/1.1/collections/entries.json
*
* To retrieve Tweets further back in time, use the value of min_position found in the current response as the max_position parameter in the next
* call to this endpoint.
*
* @param collectionId the id of the collection to retrieve tweets from
* @param count optional. Specifies the maximum number of results to include in the response 1-200. {@link Position#getWasTruncated()} will
* indicate if more tweets in collection
* @param maxPosition optional. Returns results with a position value less than or equal to the specified position (tweetId in collection)
* @param minPosition optional. Returns results with a position greater than the specified position (tweetId in collection)
*/
CollectionsResponse collectionsEntries(String collectionId, int count, String maxPosition, String minPosition);
/**
* Destroys a collection by id. See https://api.twitter.com/1.1/collections/destroy.json
*
* @param collectionId the identifier of the collection to destroy
* @return {@link CollectionsResponse#isDestroyed()}
*/
CollectionsResponse collectionsDestroy(String collectionId);
/**
* Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order. Calling
* https://api.twitter.com/1.1/direct_messages/events/list.json
*/
@Deprecated
List<DirectMessage> getDmList();
/**
* Returns all Direct Message events (both sent and received) within the last 30 days. Sorted in reverse-chronological order. Calling
* https://api.twitter.com/1.1/direct_messages/events/list.json
*
* @param count Number of direct messages to be returned
*/
@Deprecated
List<DirectMessage> getDmList(int count);
/**
* Returns a single Direct Message event by the given id.
*
* @param dmId The id of the Direct Message event that should be returned.
*/
@Deprecated
DirectMessage getDm(String dmId);
/**
* Publishes a new message_create event resulting in a Direct Message sent to a specified user from the authenticating user
*
* @param text defining the content to deliver to the reciepient
* @param userId The ID of the user who should receive the direct message.
*/
@Deprecated
DmEvent postDm(String text, String userId);
}