Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add non-public tweet metrics and misc fields for API v2 #366

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions src/main/java/io/github/redouane59/twitter/TwitterClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,12 @@ public class TwitterClient implements ITwitterClientV1, ITwitterClientV2, ITwitt
.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false)
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.findAndRegisterModules();
public static final String TWEET_FIELDS = "tweet.fields";
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use the same code style to avoid this

public static final String ALL_TWEET_FIELDS_PUBLIC =
public static final String TWEET_FIELDS = "tweet.fields";
public static final String ALL_TWEET_FIELDS_PUBLIC =
"attachments,author_id,created_at,entities,geo,id,in_reply_to_user_id,lang,possibly_sensitive,referenced_tweets,source,text,withheld,context_annotations,conversation_id,reply_settings,public_metrics";
public static final String ALL_TWEET_FIELDS_NON_PUBLIC =
ALL_TWEET_FIELDS_PUBLIC + ",non_public_metrics,organic_metrics";
public static final String ALL_TWEET_FIELDS_NON_PUBLIC_PROMOTED =
ALL_TWEET_FIELDS_NON_PUBLIC + ",promoted_metrics";
public static final String EXPANSION = "expansions";
public static final String ALL_TWEET_FIELDS_NON_PUBLIC = ALL_TWEET_FIELDS_PUBLIC + ",non_public_metrics,organic_metrics";
public static final String ALL_TWEET_FIELDS_NON_PUBLIC_PROMOTED = ALL_TWEET_FIELDS_NON_PUBLIC + ",promoted_metrics";
public static final String EXPANSION = "expansions";
public static final String
ALL_EXPANSIONS =
"author_id,entities.mentions.username,in_reply_to_user_id,referenced_tweets.id,referenced_tweets.id.author_id,attachments.media_keys,geo.place_id";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,9 @@ public <T> Optional<T> makeRequest(OAuthRequest request, boolean signRequired, C
} else if (response.getCode() < 200 || response.getCode() > 299) {
logApiError(request.getVerb().name(), request.getUrl(), stringResponse, response.getCode());
}
LOGGER.info("Rate limit exceeded, new retry in " + ConverterHelper.getSecondsAsText(retryAfter) + " at " + ConverterHelper.minutesBeforeNow(
-retryAfter / 60).format(DateTimeFormatter.ofPattern("HH:mm")));
Thread.sleep(1000L * retryAfter);
return makeRequest(request, false, classType); // We have already signed if it was requested
} else if (response.getCode() < 200 || response.getCode() > 299) {
logApiError(request.getVerb().name(), request.getUrl(), stringResponse, response.getCode());
} else if (stringResponse != null && stringResponse.startsWith("{\"errors\":")) {
throw new NoPermissionException(stringResponse);
result = convert(stringResponse, classType);
} catch (IOException ex) {
LOGGER.error("Error occupied on executing request", ex);
}
return Optional.ofNullable(result);
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.