feat(jotform): add jotform integration
This commit is contained in:
1
packages/backend/src/apps/jotform/assets/favicon.svg
Normal file
1
packages/backend/src/apps/jotform/assets/favicon.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" class="jff-logo-img" width="53" height="59" viewBox="0 0 53 59" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M14.4509 55.1332C15.5462 56.1951 14.7721 58.0143 13.2168 58.0143H3.4831C1.56265 58.0143 0 56.4995 0 54.6377V45.2017C0 43.6939 1.87664 42.9436 2.97195 44.0054L14.4509 55.1332Z" fill="#0A1551"></path><path d="M29.6655 55.8676C26.7843 53.0052 26.7843 48.3642 29.6655 45.5018L40.0638 35.1713C42.945 32.3089 47.6164 32.3089 50.4976 35.1713C53.3788 38.0338 53.3788 42.6747 50.4976 45.5371L40.0993 55.8676C37.2181 58.73 32.5468 58.73 29.6655 55.8676Z" fill="#FFB629"></path><path d="M2.1968 29.9101C-0.684414 27.0476 -0.684413 22.4067 2.1968 19.5443L19.696 2.14685C22.5772 -0.71559 27.2486 -0.715594 30.1298 2.14685C33.011 5.00929 33.011 9.65022 30.1298 12.5127L12.6306 29.9101C9.74937 32.7725 5.078 32.7725 2.1968 29.9101Z" fill="#0099FF"></path><path d="M16.5015 42.3095C13.6203 39.4471 13.6203 34.8062 16.5015 31.9437L40.1461 8.45322C43.0273 5.59079 47.6986 5.59079 50.5798 8.45322C53.4611 11.3157 53.4611 15.9566 50.5798 18.819L26.9353 42.3095C24.0541 45.1719 19.3827 45.1719 16.5015 42.3095Z" fill="#FF6100"></path></svg>
|
After Width: | Height: | Size: 1.2 KiB |
32
packages/backend/src/apps/jotform/auth/index.js
Normal file
32
packages/backend/src/apps/jotform/auth/index.js
Normal file
@@ -0,0 +1,32 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'instanceUrl',
|
||||
label: 'Jotform instance URL',
|
||||
type: 'string',
|
||||
required: false,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: 'https://${subdomain}.jotform.com',
|
||||
description: 'If you have an enterprise plan, you can use your api url.',
|
||||
clickToCopy: true,
|
||||
},
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'Jotform API key of your account.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
};
|
@@ -0,0 +1,8 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
const user = await getCurrentUser($);
|
||||
return !!user.username;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
14
packages/backend/src/apps/jotform/auth/verify-credentials.js
Normal file
14
packages/backend/src/apps/jotform/auth/verify-credentials.js
Normal file
@@ -0,0 +1,14 @@
|
||||
import getCurrentUser from '../common/get-current-user.js';
|
||||
|
||||
const verifyCredentials = async ($) => {
|
||||
const user = await getCurrentUser($);
|
||||
|
||||
const screenName = [user.username, user.email].filter(Boolean).join(' @ ');
|
||||
|
||||
await $.auth.set({
|
||||
screenName,
|
||||
apiKey: $.auth.data.apiKey,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,9 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers['APIKEY'] = `${$.auth.data.apiKey}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
@@ -0,0 +1,7 @@
|
||||
const getCurrentUser = async ($) => {
|
||||
const response = await $.http.get('/user');
|
||||
const currentUser = response.data.content;
|
||||
return currentUser;
|
||||
};
|
||||
|
||||
export default getCurrentUser;
|
11
packages/backend/src/apps/jotform/common/set-base-url.js
Normal file
11
packages/backend/src/apps/jotform/common/set-base-url.js
Normal file
@@ -0,0 +1,11 @@
|
||||
const setBaseUrl = ($, requestConfig) => {
|
||||
if ($.auth.data.instanceUrl) {
|
||||
requestConfig.baseURL = $.auth.data.instanceUrl;
|
||||
} else if ($.app.apiBaseUrl) {
|
||||
requestConfig.baseURL = $.app.apiBaseUrl;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default setBaseUrl;
|
17
packages/backend/src/apps/jotform/index.js
Normal file
17
packages/backend/src/apps/jotform/index.js
Normal file
@@ -0,0 +1,17 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
import setBaseUrl from './common/set-base-url.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'Jotform',
|
||||
key: 'jotform',
|
||||
iconUrl: '{BASE_URL}/apps/jotform/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/jotform/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: 'https://www.jotform.com',
|
||||
apiBaseUrl: 'https://api.jotform.com',
|
||||
primaryColor: 'FF6100',
|
||||
beforeRequest: [setBaseUrl, addAuthHeader],
|
||||
auth,
|
||||
});
|
@@ -252,6 +252,12 @@ export default defineConfig({
|
||||
{ text: 'Connection', link: '/apps/invoice-ninja/connection' },
|
||||
],
|
||||
},
|
||||
{
|
||||
text: 'Jotform',
|
||||
collapsible: true,
|
||||
collapsed: true,
|
||||
items: [{ text: 'Connection', link: '/apps/jotform/connection' }],
|
||||
},
|
||||
{
|
||||
text: 'Mailchimp',
|
||||
collapsible: true,
|
||||
|
12
packages/docs/pages/apps/jotform/connection.md
Normal file
12
packages/docs/pages/apps/jotform/connection.md
Normal file
@@ -0,0 +1,12 @@
|
||||
# Jotform
|
||||
|
||||
:::info
|
||||
This page explains the steps you need to follow to set up the Jotform
|
||||
connection in Automatisch. If any of the steps are outdated, please let us know!
|
||||
:::
|
||||
|
||||
1. Login to your Jotform account: [https://www.jotform.com/](https://www.jotform.com/).
|
||||
2. Click on your account image and go to **Settings**.
|
||||
3. Click on the **API** tab on the left.
|
||||
4. Copy **API key** from the page to the `API Key` field on Automatisch.
|
||||
5. Now, you can start using the Jotform connection with Automatisch.
|
1
packages/docs/pages/public/favicons/jotform.svg
Normal file
1
packages/docs/pages/public/favicons/jotform.svg
Normal file
@@ -0,0 +1 @@
|
||||
<svg xmlns:xlink="http://www.w3.org/1999/xlink" class="jff-logo-img" width="53" height="59" viewBox="0 0 53 59" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true"><path d="M14.4509 55.1332C15.5462 56.1951 14.7721 58.0143 13.2168 58.0143H3.4831C1.56265 58.0143 0 56.4995 0 54.6377V45.2017C0 43.6939 1.87664 42.9436 2.97195 44.0054L14.4509 55.1332Z" fill="#0A1551"></path><path d="M29.6655 55.8676C26.7843 53.0052 26.7843 48.3642 29.6655 45.5018L40.0638 35.1713C42.945 32.3089 47.6164 32.3089 50.4976 35.1713C53.3788 38.0338 53.3788 42.6747 50.4976 45.5371L40.0993 55.8676C37.2181 58.73 32.5468 58.73 29.6655 55.8676Z" fill="#FFB629"></path><path d="M2.1968 29.9101C-0.684414 27.0476 -0.684413 22.4067 2.1968 19.5443L19.696 2.14685C22.5772 -0.71559 27.2486 -0.715594 30.1298 2.14685C33.011 5.00929 33.011 9.65022 30.1298 12.5127L12.6306 29.9101C9.74937 32.7725 5.078 32.7725 2.1968 29.9101Z" fill="#0099FF"></path><path d="M16.5015 42.3095C13.6203 39.4471 13.6203 34.8062 16.5015 31.9437L40.1461 8.45322C43.0273 5.59079 47.6986 5.59079 50.5798 8.45322C53.4611 11.3157 53.4611 15.9566 50.5798 18.819L26.9353 42.3095C24.0541 45.1719 19.3827 45.1719 16.5015 42.3095Z" fill="#FF6100"></path></svg>
|
After Width: | Height: | Size: 1.2 KiB |
Reference in New Issue
Block a user