feat: Implement search tweet trigger step for twitter
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
3f7a888429
commit
ab82134b88
27
packages/backend/src/apps/twitter/triggers/search-tweet.ts
Normal file
27
packages/backend/src/apps/twitter/triggers/search-tweet.ts
Normal file
@@ -0,0 +1,27 @@
|
||||
import TwitterApi, { TwitterApiTokens } from 'twitter-api-v2';
|
||||
import { IJSONObject } from '@automatisch/types';
|
||||
|
||||
export default class SearchTweet {
|
||||
client: TwitterApi;
|
||||
parameters: IJSONObject;
|
||||
|
||||
constructor(connectionData: IJSONObject, parameters: IJSONObject) {
|
||||
this.client = new TwitterApi({
|
||||
appKey: connectionData.consumerKey,
|
||||
appSecret: connectionData.consumerSecret,
|
||||
accessToken: connectionData.accessToken,
|
||||
accessSecret: connectionData.accessSecret,
|
||||
} as TwitterApiTokens);
|
||||
|
||||
this.parameters = parameters;
|
||||
}
|
||||
|
||||
async run() {
|
||||
const response = await this.client.v2.get('tweets/search/recent', {
|
||||
query: this.parameters.searchTerm as string,
|
||||
max_results: 100,
|
||||
});
|
||||
|
||||
return response.data;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user