refactor: Adjust create tweet action to use new http client

This commit is contained in:
Faruk AYDIN
2022-08-20 00:49:01 +03:00
committed by Ali BARIN
parent 17010f9283
commit cd6c5216ff
5 changed files with 56 additions and 19 deletions

View File

@@ -1,23 +1,17 @@
import TwitterApi, { TwitterApiTokens } from 'twitter-api-v2';
import { IJSONObject } from '@automatisch/types';
import TwitterClient from '../client';
export default class CreateTweet {
client: TwitterApi;
parameters: IJSONObject;
client: TwitterClient;
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;
constructor(client: TwitterClient) {
this.client = client;
}
async run() {
const tweet = await this.client.v1.tweet(this.parameters.tweet as string);
return tweet;
const response = await this.client.createTweet.run(
this.client.parameters.tweet as string
);
return response.data.data;
}
}