feat: Implement initial version of processor
This commit is contained in:

committed by
Ömer Faruk Aydın

parent
4a8c3988c2
commit
ba2b5afe2b
@@ -1,27 +1,24 @@
|
||||
import TwitterApi from 'twitter-api-v2';
|
||||
|
||||
export default class CreateTweet {
|
||||
client: any
|
||||
parameters: any
|
||||
client: any;
|
||||
parameters: any;
|
||||
|
||||
constructor(connectionData: any, parameters: any) {
|
||||
this.client = new TwitterApi({
|
||||
appKey: connectionData.consumerKey,
|
||||
appSecret: connectionData.consumerSecret,
|
||||
accessToken: connectionData.accessToken,
|
||||
accessSecret: connectionData.accessSecret
|
||||
accessSecret: connectionData.accessSecret,
|
||||
});
|
||||
|
||||
this.parameters = parameters;
|
||||
if (parameters) {
|
||||
this.parameters = JSON.parse(parameters);
|
||||
}
|
||||
}
|
||||
|
||||
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];
|
||||
const tweet = await this.client.v1.tweet(this.parameters.tweet);
|
||||
return tweet;
|
||||
}
|
||||
}
|
||||
|
@@ -3,13 +3,13 @@ import Triggers from './triggers';
|
||||
import Actions from './actions';
|
||||
|
||||
export default class Twitter {
|
||||
authenticationClient: any
|
||||
triggers: any
|
||||
actions: any
|
||||
authenticationClient: any;
|
||||
triggers: any;
|
||||
actions: any;
|
||||
|
||||
constructor(connectionData: any) {
|
||||
constructor(connectionData: any, parameters: any) {
|
||||
this.authenticationClient = new Authentication(connectionData);
|
||||
this.triggers = new Triggers(connectionData);
|
||||
this.actions = new Actions(connectionData, {});
|
||||
this.actions = new Actions(connectionData, parameters);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user