-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathLikesApi.java
More file actions
338 lines (287 loc) · 15.4 KB
/
LikesApi.java
File metadata and controls
338 lines (287 loc) · 15.4 KB
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
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
/*
Copyright 2020 Twitter, Inc.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
https://openapi-generator.tech
Do not edit the class manually.
*/
package com.twitter.clientlib.api;
import com.google.gson.reflect.TypeToken;
import com.twitter.clientlib.ApiCallback;
import com.twitter.clientlib.ApiException;
import com.twitter.clientlib.ApiResponse;
import com.twitter.clientlib.Pair;
import com.twitter.clientlib.model.*;
import java.io.InputStream;
import java.lang.reflect.Type;
import java.time.OffsetDateTime;
import java.util.*;
public class LikesApi extends ApiCommon {
private okhttp3.Call getLikesFirehoseStreamCall(Integer backfillMinutes, Integer partition, OffsetDateTime startTime, OffsetDateTime endTime, Set<String> likeFields ,Set<String> tweetFields, Set<String> expansions, Set<String> userFields, final ApiCallback _callback) throws ApiException {
Object localVarPostBody = null;
// create path and map variables
String localVarPath = "/2/likes/firehose/stream";
List<Pair> localVarQueryParams = new ArrayList<Pair>();
List<Pair> localVarCollectionQueryParams = new ArrayList<Pair>();
Map<String, String> localVarHeaderParams = new HashMap<String, String>();
Map<String, String> localVarCookieParams = new HashMap<String, String>();
Map<String, Object> localVarFormParams = new HashMap<String, Object>();
if (backfillMinutes != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("backfill_minutes", backfillMinutes));
}
if (partition != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("partition", partition));
}
if (startTime != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("start_time", startTime));
}
if (endTime != null) {
localVarQueryParams.addAll(localVarApiClient.parameterToPair("end_time", endTime));
}
if (tweetFields != null) {
localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "tweet.fields", tweetFields));
}
if (likeFields != null) {
localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "like.fields", likeFields));
}
if (expansions != null) {
localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "expansions", expansions));
}
if (userFields != null) {
localVarCollectionQueryParams.addAll(localVarApiClient.parameterToPairs("csv", "user.fields", userFields));
}
final String[] localVarAccepts = {
"application/json", "application/problem+json"
};
final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts);
if (localVarAccept != null) {
localVarHeaderParams.put("Accept", localVarAccept);
}
final String[] localVarContentTypes = {
};
final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes);
if (localVarContentType != null) {
localVarHeaderParams.put("Content-Type", localVarContentType);
}
String[] localVarAuthNames = new String[]{"BearerToken"};
return localVarApiClient.buildCall(localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, reduceAuthNames(localVarAuthNames), _callback);
}
@SuppressWarnings("rawtypes")
private okhttp3.Call getLikesFirehoseStreamValidateBeforeCall(Integer backfillMinutes, Integer partition, OffsetDateTime startTime, OffsetDateTime endTime, Set<String> likeFields, Set<String> tweetFields, Set<String> expansions, Set<String> userFields, final ApiCallback _callback) throws ApiException {
// verify the required parameter 'partition' is set
if (partition == null) {
throw new ApiException("Missing the required parameter 'partition' when calling getLikesFirehoseStream(Async)");
}
okhttp3.Call localVarCall = getLikesFirehoseStreamCall(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields, _callback);
return localVarCall;
}
private InputStream getLikesFirehoseStreamWithHttpInfo(Integer backfillMinutes, Integer partition, OffsetDateTime startTime, OffsetDateTime endTime, Set<String> likeFields, Set<String> tweetFields, Set<String> expansions, Set<String> userFields) throws ApiException {
okhttp3.Call localVarCall = getLikesFirehoseStreamValidateBeforeCall(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields, null);
try {
Type localVarReturnType = new TypeToken<StreamingTweetResponse>() {
}.getType();
return localVarApiClient.executeStream(localVarCall, localVarReturnType);
} catch (ApiException e) {
e.setErrorObject(localVarApiClient.getJSON().getGson().fromJson(e.getResponseBody(), new TypeToken<com.twitter.clientlib.model.ProblemOrError>() {
}.getType()));
throw e;
}
}
private okhttp3.Call getLikesFirehoseStreamAsync(Integer backfillMinutes, Integer partition, OffsetDateTime startTime, OffsetDateTime endTime, Set<String> likeFields, Set<String> tweetFields, Set<String> expansions, Set<String> userFields, final ApiCallback<StreamingTweetResponse> _callback) throws ApiException {
okhttp3.Call localVarCall = getLikesFirehoseStreamValidateBeforeCall(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields, _callback);
Type localVarReturnType = new TypeToken<StreamingTweetResponse>() {
}.getType();
localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback);
return localVarCall;
}
public class APIgetLikesFirehoseStreamRequest {
private final Integer partition;
private Integer backfillMinutes;
private OffsetDateTime startTime;
private OffsetDateTime endTime;
private Set<String> likeFields;
private Set<String> tweetFields;
private Set<String> expansions;
private Set<String> userFields;
private final Set<String> likeFieldsAll = new HashSet<>(Arrays.asList("created_at", "id", "liked_tweet_id", "liking_user_id", "timestamp_ms"));
private final Set<String> tweetFieldsAll = new HashSet<>(Arrays.asList("attachments", "author_id", "card_uri", "context_annotations", "conversation_id", "created_at", "edit_controls", "edit_history_tweet_ids", "entities", "geo", "id", "in_reply_to_user_id", "lang", "non_public_metrics", "note_tweet", "organic_metrics", "possibly_sensitive", "promoted_metrics", "public_metrics", "referenced_tweets", "reply_settings", "source", "text", "withheld"));
private final Set<String> expansionsAll = new HashSet<>(Arrays.asList("liked_tweet_id", "liking_user_id"));
private final Set<String> userFieldsAll = new HashSet<>(Arrays.asList("connection_status", "created_at", "description", "entities", "id", "location", "most_recent_tweet_id", "name", "pinned_tweet_id", "profile_image_url", "protected", "public_metrics", "receives_your_dm", "subscription_type", "url", "username", "verified", "verified_type", "withheld"));
private boolean isExclude = false;
public APIgetLikesFirehoseStreamRequest excludeInputFields() {
isExclude = true;
return this;
}
private APIgetLikesFirehoseStreamRequest(Integer partition) {
this.partition = partition;
}
/**
* Set backfillMinutes
*
* @param backfillMinutes The number of minutes of backfill requested. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest backfillMinutes(Integer backfillMinutes) {
this.backfillMinutes = backfillMinutes;
return this;
}
/**
* Set startTime
*
* @param startTime YYYY-MM-DDTHH:mm:ssZ. The earliest UTC timestamp to which the Tweets will be provided. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest startTime(OffsetDateTime startTime) {
this.startTime = startTime;
return this;
}
/**
* Set endTime
*
* @param endTime YYYY-MM-DDTHH:mm:ssZ. The latest UTC timestamp to which the Tweets will be provided. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest endTime(OffsetDateTime endTime) {
this.endTime = endTime;
return this;
}
/**
* Set likeFields
*
* @param likeFields A comma separated list of Tweet fields to display. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest likeFields(Set<String> likeFields) {
this.likeFields = likeFields;
return this;
}
/**
* Set tweetFields
*
* @param tweetFields A comma separated list of Tweet fields to display. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest tweetFields(Set<String> tweetFields) {
this.tweetFields = tweetFields;
return this;
}
/**
* Set expansions
*
* @param expansions A comma separated list of fields to expand. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest expansions(Set<String> expansions) {
this.expansions = expansions;
return this;
}
/**
* Set userFields
*
* @param userFields A comma separated list of User fields to display. (optional)
* @return APIgetLikesFirehoseStreamRequest
*/
public APIgetLikesFirehoseStreamRequest userFields(Set<String> userFields) {
this.userFields = userFields;
return this;
}
/**
* Build call for getLikesFirehoseStream
*
* @param _callback ApiCallback API callback
* @return Call to execute
* @throws ApiException If fail to serialize the request body object
* @http.response.details <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> The request has succeeded. </td><td> - </td></tr>
* <tr><td> 0 </td><td> The request has failed. </td><td> - </td></tr>
* </table>
*/
public okhttp3.Call buildCall(final ApiCallback _callback) throws ApiException {
return getLikesFirehoseStreamCall(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields, _callback);
}
/**
* Execute getLikesFirehoseStream request
*
* @return StreamingTweetResponse
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> The request has succeeded. </td><td> - </td></tr>
* <tr><td> 0 </td><td> The request has failed. </td><td> - </td></tr>
* </table>
*/
public InputStream execute() throws ApiException {
return getLikesFirehoseStreamWithHttpInfo(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields);
}
/**
* Calls the API using a retry mechanism to handle rate limits errors.
*/
public InputStream execute(Integer retries) throws ApiException {
InputStream localVarResp;
try {
localVarResp = execute();
} catch (ApiException e) {
if (handleRateLimit(e, retries)) {
return execute(retries - 1);
} else {
throw e;
}
}
return localVarResp;
}
/**
* Execute getLikesFirehoseStream request with HTTP info returned
*
* @return ApiResponse<StreamingTweetResponse>
* @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body
* @http.response.details <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> The request has succeeded. </td><td> - </td></tr>
* <tr><td> 0 </td><td> The request has failed. </td><td> - </td></tr>
* </table>
*/
public InputStream executeWithHttpInfo() throws ApiException {
return getLikesFirehoseStreamWithHttpInfo(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields);
}
/**
* Execute getLikesFirehoseStream request (asynchronously)
*
* @param _callback The callback to be executed when the API call finishes
* @return The request call
* @throws ApiException If fail to process the API call, e.g. serializing the request body object
* @http.response.details <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> The request has succeeded. </td><td> - </td></tr>
* <tr><td> 0 </td><td> The request has failed. </td><td> - </td></tr>
* </table>
*/
public okhttp3.Call executeAsync(final ApiCallback<StreamingTweetResponse> _callback) throws ApiException {
return getLikesFirehoseStreamAsync(backfillMinutes, partition, startTime, endTime, likeFields, tweetFields, expansions, userFields, _callback);
}
}
/**
* Firehose stream
* Streams 100% of public Likes.
*
* @param partition The partition number. (required)
* @return APIgetLikesFirehoseStreamRequest
* @http.response.details <table summary="Response Details" border="1">
* <tr><td> Status Code </td><td> Description </td><td> Response Headers </td></tr>
* <tr><td> 200 </td><td> The request has succeeded. </td><td> - </td></tr>
* <tr><td> 0 </td><td> The request has failed. </td><td> - </td></tr>
* </table>
*/
public APIgetLikesFirehoseStreamRequest getLikesFirehoseStream(Integer partition) {
return new APIgetLikesFirehoseStreamRequest(partition);
}
}