refactor: Adjust architecture for twitter client and user tweet trigger

This commit is contained in:
Faruk AYDIN
2022-08-10 22:46:40 +03:00
parent a4abd7e1cd
commit bb68b2dea1
12 changed files with 305 additions and 108 deletions

View File

@@ -0,0 +1,30 @@
import TwitterClient from '../client';
export default class UserTweet {
client: TwitterClient;
constructor(client: TwitterClient) {
this.client = client;
}
async run() {
return this.getTweets();
}
async testRun() {
return this.getTweets();
}
async getTweets() {
const userResponse = await this.client.getUserByUsername.run(
this.client.parameters.username as string
);
const userId = userResponse.data.data.id;
const tweetsResponse = await this.client.getUserTweets.run(userId);
const tweets = tweetsResponse.data.data;
return tweets;
}
}