feat(carbone): add add-template action

This commit is contained in:
moaaz
2023-11-08 08:33:12 +02:00
committed by Ali BARIN
parent 112b05f7ad
commit bc337c588a
3 changed files with 40 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
import defineAction from '../../../../helpers/define-action';
export default defineAction({
name: 'Add Template',
key: 'addTemplate',
description:
'Creates an attachment of a specified object by given parent ID.',
arguments: [
{
label: 'Templete Data',
key: 'templateData',
type: 'string' as const,
required: true,
variables: true,
description: 'The content of your new Template in XML/HTML format.',
},
],
async run($) {
const templateData = $.step.parameters.templateData as string;
const base64Data = Buffer.from(templateData).toString('base64');
const dataURI = `data:application/xml;base64,${base64Data}`;
const body = JSON.stringify({ template: dataURI });
const response = await $.http.post('/template', body, {
headers: {
'Content-Type': 'application/json',
},
});
$.setActionItem({ raw: response.data });
},
});

View File

@@ -0,0 +1,3 @@
import addTemplate from './add-template';
export default [addTemplate];

View File

@@ -1,6 +1,7 @@
import defineApp from '../../helpers/define-app';
import addAuthHeader from './common/add-auth-header';
import auth from './auth';
import actions from './actions';
export default defineApp({
name: 'Carbone',
@@ -13,4 +14,5 @@ export default defineApp({
primaryColor: '6f42c1',
beforeRequest: [addAuthHeader],
auth,
actions,
});