Skip to content

Commit 147d5c6

Browse files
committed
v2.getQuoteTweets
1 parent 93e3545 commit 147d5c6

File tree

4 files changed

+59
-47
lines changed

4 files changed

+59
-47
lines changed

twitter4j-v2-support/src/main/kotlin/twitter4j/QuoteTweetsEx.kt

Lines changed: 0 additions & 46 deletions
This file was deleted.

twitter4j-v2-support/src/main/kotlin/twitter4j/TwitterV2.kt

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,29 @@ interface TwitterV2 {
221221
userFields: String? = null,
222222
): UsersResponse
223223

224+
/**
225+
* Returns Quote Tweets for a Tweet specified by the requested Tweet ID.
226+
*
227+
* @throws TwitterException when Twitter service or network is unavailable
228+
* @see "https://developer.twitter.com/en/docs/twitter-api/tweets/quote-tweets/api-reference/get-tweets-id-quote_tweets"
229+
*/
230+
@Throws(TwitterException::class)
231+
fun getQuoteTweets(
232+
/**
233+
* Unique identifier of the Tweet to request.
234+
*/
235+
id: Long,
236+
expansions: String? = null,
237+
maxResults: Int? = null,
238+
exclude: String? = null,
239+
mediaFields: String? = null,
240+
paginationToken: PaginationToken? = null,
241+
placeFields: String? = null,
242+
pollFields: String? = null,
243+
tweetFields: String? = null,
244+
userFields: String? = null,
245+
): TweetsResponse
246+
224247
/**
225248
* Causes the user ID identified in the path parameter to Retweet the target Tweet.
226249
*

twitter4j-v2-support/src/main/kotlin/twitter4j/TwitterV2Impl.kt

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,41 @@ class TwitterV2Impl(private val twitter: Twitter) : TwitterV2 {
544544
)
545545
}
546546

547+
@Throws(TwitterException::class)
548+
override fun getQuoteTweets(
549+
/**
550+
* Unique identifier of the Tweet to request.
551+
*/
552+
id: Long,
553+
expansions: String?,
554+
maxResults: Int?,
555+
exclude: String?,
556+
mediaFields: String?,
557+
paginationToken: PaginationToken?,
558+
placeFields: String?,
559+
pollFields: String?,
560+
tweetFields: String?,
561+
userFields: String?,
562+
): TweetsResponse {
563+
564+
val params = ArrayList<HttpParameter>()
565+
566+
V2Util.addHttpParamIfNotNull(params, "expansions", expansions)
567+
V2Util.addHttpParamIfNotNull(params, "max_results", maxResults)
568+
V2Util.addHttpParamIfNotNull(params, "exclude", exclude)
569+
V2Util.addHttpParamIfNotNull(params, "pagination_token", paginationToken)
570+
V2Util.addHttpParamIfNotNull(params, "media.fields", mediaFields)
571+
V2Util.addHttpParamIfNotNull(params, "place.fields", placeFields)
572+
V2Util.addHttpParamIfNotNull(params, "poll.fields", pollFields)
573+
V2Util.addHttpParamIfNotNull(params, "tweet.fields", tweetFields)
574+
V2Util.addHttpParamIfNotNull(params, "user.fields", userFields)
575+
576+
return V2ResponseFactory().createTweetsResponse(
577+
get(conf.v2Configuration.baseURL + "tweets/" + id + "/quote_tweets", params.toTypedArray()),
578+
conf
579+
)
580+
}
581+
547582
@Throws(TwitterException::class)
548583
override fun retweet(
549584
userId: Long,

twitter4j-v2-support/src/test/kotlin/twitter4j/QuoteTweetsTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class QuoteTweetsTest {
1111
fun getQuoteTweets_full() {
1212

1313
// https://twitter.com/TwitterJP/status/1522058667377696769
14-
val res = twitter.getQuoteTweets(
14+
val res = twitter.v2.getQuoteTweets(
1515
1522058667377696769L,
1616
V2DefaultFields.expansions,
1717
10,

0 commit comments

Comments
 (0)