Merge pull request #1561 from automatisch/AUT-614
feat(mailerlite): add mailerlite integration
This commit is contained in:
1
packages/backend/src/apps/mailerlite/assets/favicon.svg
Normal file
1
packages/backend/src/apps/mailerlite/assets/favicon.svg
Normal file
File diff suppressed because one or more lines are too long
After Width: | Height: | Size: 9.0 KiB |
33
packages/backend/src/apps/mailerlite/auth/index.js
Normal file
33
packages/backend/src/apps/mailerlite/auth/index.js
Normal file
@@ -0,0 +1,33 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
import isStillVerified from './is-still-verified.js';
|
||||
|
||||
export default {
|
||||
fields: [
|
||||
{
|
||||
key: 'screenName',
|
||||
label: 'Screen Name',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description:
|
||||
'Screen name of your connection to be used on Automatisch UI.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
{
|
||||
key: 'apiKey',
|
||||
label: 'API Key',
|
||||
type: 'string',
|
||||
required: true,
|
||||
readOnly: false,
|
||||
value: null,
|
||||
placeholder: null,
|
||||
description: 'MailerLite API key of your account.',
|
||||
clickToCopy: false,
|
||||
},
|
||||
],
|
||||
|
||||
verifyCredentials,
|
||||
isStillVerified,
|
||||
};
|
@@ -0,0 +1,8 @@
|
||||
import verifyCredentials from './verify-credentials.js';
|
||||
|
||||
const isStillVerified = async ($) => {
|
||||
await verifyCredentials($);
|
||||
return true;
|
||||
};
|
||||
|
||||
export default isStillVerified;
|
@@ -0,0 +1,10 @@
|
||||
const verifyCredentials = async ($) => {
|
||||
await $.http.get('/campaigns');
|
||||
|
||||
await $.auth.set({
|
||||
screenName: $.auth.data.screenName,
|
||||
apiKey: $.auth.data.apiKey,
|
||||
});
|
||||
};
|
||||
|
||||
export default verifyCredentials;
|
@@ -0,0 +1,9 @@
|
||||
const addAuthHeader = ($, requestConfig) => {
|
||||
if ($.auth.data?.apiKey) {
|
||||
requestConfig.headers.Authorization = `Bearer ${$.auth.data.apiKey}`;
|
||||
}
|
||||
|
||||
return requestConfig;
|
||||
};
|
||||
|
||||
export default addAuthHeader;
|
16
packages/backend/src/apps/mailerlite/index.js
Normal file
16
packages/backend/src/apps/mailerlite/index.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import defineApp from '../../helpers/define-app.js';
|
||||
import addAuthHeader from './common/add-auth-header.js';
|
||||
import auth from './auth/index.js';
|
||||
|
||||
export default defineApp({
|
||||
name: 'MailerLite',
|
||||
key: 'mailerlite',
|
||||
iconUrl: '{BASE_URL}/apps/mailerlite/assets/favicon.svg',
|
||||
authDocUrl: 'https://automatisch.io/docs/apps/mailerlite/connection',
|
||||
supportsConnections: true,
|
||||
baseUrl: 'https://www.mailerlite.com',
|
||||
apiBaseUrl: 'https://connect.mailerlite.com/api',
|
||||
primaryColor: '09C269',
|
||||
beforeRequest: [addAuthHeader],
|
||||
auth,
|
||||
});
|
Reference in New Issue
Block a user