feat: Implement create tweet action

This commit is contained in:
Faruk AYDIN
2022-10-18 18:04:19 +02:00
committed by Ali BARIN
parent a5e114ac68
commit 3004cf1115
2 changed files with 60 additions and 3 deletions

View File

@@ -0,0 +1,48 @@
import { IActionOutput } from '@automatisch/types';
import defineAction from '../../../../helpers/define-action';
export default defineAction({
name: 'Create Tweet',
key: 'createTweet',
description: 'Create a tweet.',
substeps: [
{
key: 'chooseConnection',
name: 'Choose connection',
},
{
key: 'chooseAction',
name: 'Set up action',
arguments: [
{
label: 'Tweet body',
key: 'tweet',
type: 'string',
required: true,
description: 'The content of your new tweet.',
variables: true,
},
],
},
{
key: 'testStep',
name: 'Test action',
},
],
async run($) {
const text = $.step.parameters.tweet;
const response = await $.http.post('/2/tweets', {
text,
});
const tweet: IActionOutput = {
data: {
raw: response.data,
},
error: response?.integrationError,
};
return tweet;
},
});