@@ -46,6 +46,9 @@ import {
46
46
ListGetV2Result ,
47
47
GetListTimelineV2Params ,
48
48
ListTimelineV2Result ,
49
+ TweetRetweetedOrLikedByV2Params ,
50
+ TweetRetweetedOrLikedByV2ParamsWithPaginator ,
51
+ TweetRetweetedOrLikedByV2ParamsWithoutPaginator ,
49
52
} from '../types' ;
50
53
import {
51
54
TweetSearchAllV2Paginator ,
@@ -59,7 +62,7 @@ import {
59
62
TweetV2ListTweetsPaginator ,
60
63
} from '../paginators' ;
61
64
import TwitterApiv2LabsReadOnly from '../v2-labs/client.v2.labs.read' ;
62
- import { UserBlockingUsersV2Paginator , UserFollowersV2Paginator , UserFollowingV2Paginator , UserListFollowersV2Paginator , UserListMembersV2Paginator , UserMutingUsersV2Paginator } from '../paginators/user.paginator.v2' ;
65
+ import { TweetLikingUsersV2Paginator , TweetRetweetersUsersV2Paginator , UserBlockingUsersV2Paginator , UserFollowersV2Paginator , UserFollowingV2Paginator , UserListFollowersV2Paginator , UserListMembersV2Paginator , UserMutingUsersV2Paginator } from '../paginators/user.paginator.v2' ;
63
66
import { isTweetStreamV2ErrorPayload } from '../helpers' ;
64
67
import TweetStream from '../stream/TweetStream' ;
65
68
import { PromiseOrType } from '../types/shared.types' ;
@@ -164,16 +167,52 @@ export default class TwitterApiv2ReadOnly extends TwitterApiSubClient {
164
167
* Allows you to get information about who has Retweeted a Tweet.
165
168
* https://developer.twitter.com/en/docs/twitter-api/tweets/retweets/api-reference/get-tweets-id-retweeted_by
166
169
*/
167
- public tweetRetweetedBy ( tweetId : string , options : Partial < UsersV2Params > = { } ) {
168
- return this . get < TweetV2RetweetedByResult > ( 'tweets/:id/retweeted_by' , options , { params : { id : tweetId } } ) ;
170
+ public tweetRetweetedBy ( tweetId : string , options ?: Partial < TweetRetweetedOrLikedByV2ParamsWithoutPaginator > ) : Promise < TweetV2RetweetedByResult > ;
171
+ public tweetRetweetedBy ( tweetId : string , options : TweetRetweetedOrLikedByV2ParamsWithPaginator ) : Promise < TweetRetweetersUsersV2Paginator > ;
172
+ public async tweetRetweetedBy ( tweetId : string , options : TweetRetweetedOrLikedByV2Params = { } ) {
173
+ const { asPaginator, ...parameters } = options ;
174
+ const initialRq = await this . get < TweetV2RetweetedByResult > ( 'tweets/:id/retweeted_by' , parameters as any , {
175
+ fullResponse : true ,
176
+ params : { id : tweetId } ,
177
+ } ) ;
178
+
179
+ if ( ! asPaginator ) {
180
+ return initialRq . data ;
181
+ }
182
+
183
+ return new TweetRetweetersUsersV2Paginator ( {
184
+ realData : initialRq . data ,
185
+ rateLimit : initialRq . rateLimit ! ,
186
+ instance : this ,
187
+ queryParams : parameters ,
188
+ sharedParams : { id : tweetId } ,
189
+ } ) ;
169
190
}
170
191
171
192
/**
172
193
* Allows you to get information about who has Liked a Tweet.
173
194
* https://developer.twitter.com/en/docs/twitter-api/tweets/likes/api-reference/get-tweets-id-liking_users
174
195
*/
175
- public tweetLikedBy ( tweetId : string , options : Partial < UsersV2Params > = { } ) {
176
- return this . get < TweetV2LikedByResult > ( 'tweets/:id/liking_users' , options , { params : { id : tweetId } } ) ;
196
+ public tweetLikedBy ( tweetId : string , options ?: Partial < TweetRetweetedOrLikedByV2ParamsWithoutPaginator > ) : Promise < TweetV2LikedByResult > ;
197
+ public tweetLikedBy ( tweetId : string , options : TweetRetweetedOrLikedByV2ParamsWithPaginator ) : Promise < TweetLikingUsersV2Paginator > ;
198
+ public async tweetLikedBy ( tweetId : string , options : TweetRetweetedOrLikedByV2Params = { } ) {
199
+ const { asPaginator, ...parameters } = options ;
200
+ const initialRq = await this . get < TweetV2LikedByResult > ( 'tweets/:id/liking_users' , parameters as any , {
201
+ fullResponse : true ,
202
+ params : { id : tweetId } ,
203
+ } ) ;
204
+
205
+ if ( ! asPaginator ) {
206
+ return initialRq . data ;
207
+ }
208
+
209
+ return new TweetLikingUsersV2Paginator ( {
210
+ realData : initialRq . data ,
211
+ rateLimit : initialRq . rateLimit ! ,
212
+ instance : this ,
213
+ queryParams : parameters ,
214
+ sharedParams : { id : tweetId } ,
215
+ } ) ;
177
216
}
178
217
179
218
/**
0 commit comments