Compare commits

...

5 Commits

Author SHA1 Message Date
Rıdvan Akca
01472c1fb9 feat(pdf-monkey): add find document action 2024-02-28 16:43:25 +03:00
Rıdvan Akca
703e434e5c feat(pdf-monkey): add delete document action 2024-02-28 16:29:01 +03:00
Rıdvan Akca
c12dacfa40 feat(pdf-monkey): add generate document action 2024-02-28 15:50:17 +03:00
Rıdvan Akca
71a404063c feat(pdf-monkey): add documents generated trigger 2024-02-27 16:40:51 +03:00
Rıdvan Akca
8bb7b16c0e feat(pdf-monkey): add pdf-monkey integration 2024-02-22 17:32:38 +03:00
25 changed files with 3675 additions and 1 deletions

View File

@@ -0,0 +1,29 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Delete document',
key: 'deleteDocument',
description: 'Deletes a document.',
arguments: [
{
label: 'Document ID',
key: 'documentId',
type: 'string',
required: true,
description: '',
variables: true,
},
],
async run($) {
const { documentId } = $.step.parameters;
await $.http.delete(`/v1/documents/${documentId}`);
$.setActionItem({
raw: {
result: 'successful',
},
});
},
});

View File

@@ -0,0 +1,27 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Find document',
key: 'findDocument',
description: 'Finds a document.',
arguments: [
{
label: 'Document ID',
key: 'documentId',
type: 'string',
required: true,
description: '',
variables: true,
},
],
async run($) {
const { documentId } = $.step.parameters;
const { data } = await $.http.get(`/v1/documents/${documentId}`);
$.setActionItem({
raw: data.document,
});
},
});

View File

@@ -0,0 +1,241 @@
import defineAction from '../../../../helpers/define-action.js';
export default defineAction({
name: 'Generate document',
key: 'generateDocument',
description: 'Creates a new document.',
arguments: [
{
label: 'Workspace',
key: 'workspaceId',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listWorkspaces',
},
],
},
},
{
label: 'Template',
key: 'templateId',
type: 'dropdown',
required: false,
depensOn: ['parameters.workspaceId'],
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTemplates',
},
{
name: 'parameters.workspaceId',
value: '{parameters.workspaceId}',
},
],
},
},
{
label: 'Use a Custom Json Structure?',
key: 'useCustomJsonStructure',
type: 'dropdown',
required: true,
description:
'Please indicate "yes" if you would rather create a full JSON payload instead of relying on Automatisch mapping for the Document data.',
variables: true,
options: [
{
label: 'Yes',
value: true,
},
{
label: 'No',
value: false,
},
],
additionalFields: {
type: 'query',
name: 'getDynamicFields',
arguments: [
{
name: 'key',
value: 'listDocumentData',
},
{
name: 'parameters.useCustomJsonStructure',
value: '{parameters.useCustomJsonStructure}',
},
],
},
},
{
label: 'Add Line Items?',
key: 'addLineItems',
type: 'dropdown',
required: true,
description:
'Choose "yes" to include information for Line Items (such as in an invoice).',
variables: true,
options: [
{
label: 'Yes',
value: true,
},
{
label: 'No',
value: false,
},
],
additionalFields: {
type: 'query',
name: 'getDynamicFields',
arguments: [
{
name: 'key',
value: 'listLineItems',
},
{
name: 'parameters.addLineItems',
value: '{parameters.addLineItems}',
},
],
},
},
{
label: 'Custom Filename',
key: 'customFilename',
type: 'string',
required: false,
description:
'You have the option to define a custom filename for generated documents. If left blank, a random value will be assigned.',
variables: true,
},
{
label: 'Meta Data',
key: 'metaData',
type: 'dynamic',
required: false,
description:
'Extra information appended to the generated Document but not accessible within its Template.',
fields: [
{
label: 'Key',
key: 'metaDataKey',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Value',
key: 'metaDataValue',
type: 'string',
required: false,
description: '',
variables: true,
},
],
},
],
async run($) {
const {
templateId,
useCustomJsonStructure,
customJsonPayload,
customFilename,
addLineItems,
lineItems,
documentData,
metaData,
} = $.step.parameters;
let payload = {};
let meta = {};
const documentDataObject = documentData.reduce((result, entry) => {
const key = entry.documentDataKey?.toLowerCase();
const value = entry.documentDataValue;
if (key && value) {
return {
...result,
[entry.documentDataKey?.toLowerCase()]: entry.documentDataValue,
};
}
return result;
}, {});
const lineItemsObject = lineItems.reduce((result, entry) => {
const key = entry.lineItemKey?.toLowerCase();
const value = entry.lineItemValue;
if (key && value) {
return {
...result,
[entry.lineItemKey?.toLowerCase()]: entry.lineItemValue,
};
}
return result;
}, {});
const metaDataObject = metaData.reduce((result, entry) => {
const key = entry.metaDataKey?.toLowerCase();
const value = entry.metaDataValue;
if (key && value) {
return {
...result,
[entry.metaDataKey?.toLowerCase()]: entry.metaDataValue,
};
}
return result;
}, {});
if (metaDataObject) {
meta = metaDataObject;
}
if (customFilename) {
meta._filename = customFilename;
}
if (useCustomJsonStructure) {
payload = JSON.parse(customJsonPayload);
} else {
payload = documentDataObject;
}
if (addLineItems) {
payload.lineItems = [lineItemsObject];
}
const body = {
document: {
document_template_id: templateId,
meta: JSON.stringify(meta),
payload: JSON.stringify(payload),
status: 'pending',
},
};
const { data } = await $.http.post('/v1/documents', body);
$.setActionItem({
raw: data,
});
},
});

View File

@@ -0,0 +1,5 @@
import deleteDocument from './delete-document/index.js';
import findDocument from './find-document/index.js';
import generateDocument from './generate-document/index.js';
export default [deleteDocument, findDocument, generateDocument];

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 112 KiB

View File

@@ -0,0 +1,21 @@
import verifyCredentials from './verify-credentials.js';
import isStillVerified from './is-still-verified.js';
export default {
fields: [
{
key: 'apiKey',
label: 'API Key',
type: 'string',
required: true,
readOnly: false,
value: null,
placeholder: null,
description: 'PDFMonkey API secret key of your account.',
clickToCopy: false,
},
],
verifyCredentials,
isStillVerified,
};

View File

@@ -0,0 +1,8 @@
import getCurrentUser from '../common/get-current-user.js';
const isStillVerified = async ($) => {
const currentUser = await getCurrentUser($);
return !!currentUser.id;
};
export default isStillVerified;

View File

@@ -0,0 +1,15 @@
import getCurrentUser from '../common/get-current-user.js';
const verifyCredentials = async ($) => {
const currentUser = await getCurrentUser($);
const screenName = [currentUser.desired_name, currentUser.email]
.filter(Boolean)
.join(' @ ');
await $.auth.set({
screenName,
apiKey: $.auth.data.apiKey,
});
};
export default verifyCredentials;

View File

@@ -0,0 +1,9 @@
const addAuthHeader = ($, requestConfig) => {
if ($.auth.data?.apiKey) {
requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiKey}`;
}
return requestConfig;
};
export default addAuthHeader;

View File

@@ -0,0 +1,8 @@
const getCurrentUser = async ($) => {
const response = await $.http.get('/v1/current_user');
const currentUser = response.data.current_user;
return currentUser;
};
export default getCurrentUser;

View File

@@ -0,0 +1,4 @@
import listTemplates from './list-templates/index.js';
import listWorkspaces from './list-workspaces/index.js';
export default [listTemplates, listWorkspaces];

View File

@@ -0,0 +1,39 @@
export default {
name: 'List templates',
key: 'listTemplates',
async run($) {
const templates = {
data: [],
};
const workspaceId = $.step.parameters.workspaceId;
let next = false;
const params = {
page: 'all',
'q[workspace_id]': workspaceId,
};
if (!workspaceId) {
return templates;
}
do {
const { data } = await $.http.get('/v1/document_template_cards', params);
next = data.meta.next_page;
if (!data?.document_template_cards?.length) {
return;
}
for (const template of data.document_template_cards) {
templates.data.push({
value: template.id,
name: template.identifier,
});
}
} while (next);
return templates;
},
};

View File

@@ -0,0 +1,29 @@
export default {
name: 'List workspaces',
key: 'listWorkspaces',
async run($) {
const workspaces = {
data: [],
};
let next = false;
do {
const { data } = await $.http.get('/v1/workspace_cards');
next = data.meta.next_page;
if (!data?.workspace_cards?.length) {
return;
}
for (const workspace of data.workspace_cards) {
workspaces.data.push({
value: workspace.id,
name: workspace.identifier,
});
}
} while (next);
return workspaces;
},
};

View File

@@ -0,0 +1,4 @@
import listDocumentData from './list-document-data/index.js';
import listLineItems from './list-line-items/index.js';
export default [listDocumentData, listLineItems];

View File

@@ -0,0 +1,48 @@
export default {
name: 'List document data',
key: 'listDocumentData',
async run($) {
if ($.step.parameters.useCustomJsonStructure) {
return [
{
label: 'Data for the Document (JSON Payload)',
key: 'customJsonPayload',
type: 'string',
required: false,
description:
'Use the JSON format { "firstname": "John", "lastname": "Doe" }.',
variables: true,
},
];
} else {
return [
{
label: 'Data for the Document',
key: 'documentData',
type: 'dynamic',
required: false,
description: '',
fields: [
{
label: 'Key',
key: 'documentDataKey',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Value',
key: 'documentDataValue',
type: 'string',
required: false,
description: '',
variables: true,
},
],
},
];
}
},
};

View File

@@ -0,0 +1,37 @@
export default {
name: 'List line items',
key: 'listLineItems',
async run($) {
if ($.step.parameters.addLineItems) {
return [
{
label: 'Line Items',
key: 'lineItems',
type: 'dynamic',
required: false,
description:
'Data for a single item. Available as "lineItems" in your PDFMonkey Template.',
fields: [
{
label: 'Key',
key: 'lineItemKey',
type: 'string',
required: false,
description: '',
variables: true,
},
{
label: 'Value',
key: 'lineItemValue',
type: 'string',
required: false,
description: '',
variables: true,
},
],
},
];
}
},
};

View File

@@ -0,0 +1,24 @@
import defineApp from '../../helpers/define-app.js';
import addAuthHeader from './common/add-auth-header.js';
import auth from './auth/index.js';
import triggers from './triggers/index.js';
import dynamicData from './dynamic-data/index.js';
import actions from './actions/index.js';
import dynamicFields from './dynamic-fields/index.js';
export default defineApp({
name: 'PDFMonkey',
key: 'pdf-monkey',
iconUrl: '{BASE_URL}/apps/pdf-monkey/assets/favicon.svg',
authDocUrl: 'https://automatisch.io/docs/apps/pdf-monkey/connection',
supportsConnections: true,
baseUrl: 'https://pdfmonkey.io',
apiBaseUrl: 'https://api.pdfmonkey.io/api',
primaryColor: '376794',
beforeRequest: [addAuthHeader],
auth,
triggers,
dynamicData,
actions,
dynamicFields,
});

View File

@@ -0,0 +1,99 @@
import defineTrigger from '../../../../helpers/define-trigger.js';
export default defineTrigger({
name: 'Documents Generated',
key: 'documentsGenerated',
pollInterval: 15,
description:
'Triggers upon the successful completion of document generation.',
arguments: [
{
label: 'Workspace',
key: 'workspaceId',
type: 'dropdown',
required: true,
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listWorkspaces',
},
],
},
},
{
label: 'Templates',
key: 'templateIds',
type: 'dynamic',
required: false,
description: 'Apply this trigger exclusively for particular templates.',
fields: [
{
label: 'Template',
key: 'templateId',
type: 'dropdown',
required: false,
depensOn: ['parameters.workspaceId'],
description: '',
variables: true,
source: {
type: 'query',
name: 'getDynamicData',
arguments: [
{
name: 'key',
value: 'listTemplates',
},
{
name: 'parameters.workspaceId',
value: '{parameters.workspaceId}',
},
],
},
},
],
},
],
async run($) {
const workspaceId = $.step.parameters.workspaceId;
const templateIds = $.step.parameters.templateIds;
const allTemplates = templateIds
.map((templateId) => templateId.templateId)
.join(',');
const params = {
'page[size]': 100,
'q[workspace_id]': workspaceId,
'q[status]': 'success',
};
if (!templateIds.length) {
params['q[document_template_id]'] = allTemplates;
}
let next = false;
do {
const { data } = await $.http.get('/v1/document_cards', { params });
if (!data?.document_cards?.length) {
return;
}
next = data.meta.next_page;
for (const document of data.document_cards) {
$.pushTriggerItem({
raw: document,
meta: {
internalId: document.id,
},
});
}
} while (next);
},
});

View File

@@ -0,0 +1,3 @@
import documentsGenerated from './documents-generated/index.js';
export default [documentsGenerated];

View File

@@ -252,6 +252,16 @@ export default defineConfig({
{ text: 'Connection', link: '/apps/openai/connection' },
],
},
{
text: 'PDFMonkey',
collapsible: true,
collapsed: true,
items: [
{ text: 'Triggers', link: '/apps/pdf-monkey/triggers' },
{ text: 'Actions', link: '/apps/pdf-monkey/actions' },
{ text: 'Connection', link: '/apps/pdf-monkey/connection' },
],
},
{
text: 'Pipedrive',
collapsible: true,
@@ -305,7 +315,7 @@ export default defineConfig({
collapsed: true,
items: [
{ text: 'Actions', link: '/apps/removebg/actions' },
{ text: 'Connection', link: '/apps/removebg/connection' }
{ text: 'Connection', link: '/apps/removebg/connection' },
],
},
{

View File

@@ -0,0 +1,16 @@
---
favicon: /favicons/pdf-monkey.svg
items:
- name: Generate documents
desc: Creates a new document.
- name: Find documents
desc: Finds a document.
- name: Delete documents
desc: Deletes a document.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -0,0 +1,11 @@
# PDFMonkey
:::info
This page explains the steps you need to follow to set up the PDFMonkey
connection in Automatisch. If any of the steps are outdated, please let us know!
:::
1. Login to your PDFMonkey account: [https://dashboard.pdfmonkey.io/login](https://dashboard.pdfmonkey.io/login).
2. Go to **My Account** section from your profile.
3. Copy `API SECRET KEY` from the page to the `API Key` field on Automatisch.
4. Now, you can start using the PDFMonkey connection with Automatisch.

View File

@@ -0,0 +1,12 @@
---
favicon: /favicons/pdf-monkey.svg
items:
- name: Documents Generated
desc: Triggers upon the successful completion of document generation.
---
<script setup>
import CustomListing from '../../components/CustomListing.vue'
</script>
<CustomListing />

View File

@@ -26,6 +26,7 @@ The following integrations are currently supported by Automatisch.
- [Ntfy](/apps/ntfy/actions)
- [Odoo](/apps/odoo/actions)
- [OpenAI](/apps/openai/actions)
- [PDFMonkey](/apps/pdf-monkey/actions)
- [Pipedrive](/apps/pipedrive/triggers)
- [Placetel](/apps/placetel/triggers)
- [PostgreSQL](/apps/postgresql/actions)

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 112 KiB