feat: Introduce my tweet trigger with execute step mutation

This commit is contained in:
Faruk AYDIN
2021-11-19 18:21:04 +01:00
committed by Ömer Faruk Aydın
parent 46321f19f4
commit b42cb759a5
5 changed files with 74 additions and 0 deletions

View File

@@ -1,9 +1,12 @@
import Authentication from './authentication';
import Triggers from './triggers';
export default class Twitter {
authenticationClient: any
triggers: any
constructor(connectionData: any) {
this.authenticationClient = new Authentication(connectionData);
this.triggers = new Triggers(connectionData);
}
}

View File

@@ -0,0 +1,9 @@
import MyTweet from './triggers/my-tweet';
export default class Triggers {
myTweet: any
constructor(connectionData: any) {
this.myTweet = new MyTweet(connectionData)
}
}

View File

@@ -0,0 +1,24 @@
import TwitterApi from 'twitter-api-v2';
export default class MyTweet {
client: any
constructor(connectionData: any) {
this.client = new TwitterApi({
appKey: connectionData.consumerKey,
appSecret: connectionData.consumerSecret,
accessToken: connectionData.accessToken,
accessSecret: connectionData.accessSecret
});
}
async run() {
const response = await this.client.currentUser();
const username = response.screen_name;
const userTimeline = await this.client.v1.userTimelineByUsername(username);
const fetchedTweets = userTimeline.tweets;
return fetchedTweets[0];
}
}