feat: Implement createAuthLink mutation

This commit is contained in:
Faruk AYDIN
2021-10-14 15:17:58 +02:00
committed by Ali BARIN
parent 7f17420ae0
commit bdd0843d94
11 changed files with 130 additions and 3 deletions

View File

@@ -0,0 +1,24 @@
import TwitterApi from 'twitter-api-v2';
import App from '../../models/app';
import Field from '../../types/field';
export default class Twitter {
client: any
appData: any
constructor(credentialsData: any) {
this.client = new TwitterApi({
appKey: credentialsData.consumerKey,
appSecret: credentialsData.consumerSecret
});
this.appData = App.findOneByName('twitter')
}
async createAuthLink() {
const appFields = this.appData.fields.find((field: Field) => field.key == 'oAuthRedirectUrl')
const callbackUrl = appFields.value;
return this.client.generateAuthLink(callbackUrl);
}
}