feat: Implement search tweet trigger step for twitter

This commit is contained in:
Faruk AYDIN
2022-03-12 14:27:15 +03:00
committed by Ömer Faruk Aydın
parent 3f7a888429
commit ab82134b88
4 changed files with 60 additions and 3 deletions

View 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;
}
}