🔀 Merge branch 'master' of github.com:n8n-io/n8n

This commit is contained in:
Jan Oberhauser 2021-09-15 10:37:53 +02:00
commit a26d8f38cd
2 changed files with 29 additions and 29 deletions

View file

@ -13,6 +13,10 @@ import {
OptionsWithUri,
} from 'request';
import {
capitalCase,
} from 'change-case';
/**
* Make an authenticated API request to Lemlist.
*/
@ -87,3 +91,22 @@ export async function lemlistApiRequestAllItems(
);
return returnData;
}
export function getEvents() {
const events = [
'*',
'emailsBounced',
'emailsClicked',
'emailsFailed',
'emailsInterested',
'emailsNotInterested',
'emailsOpened',
'emailsReplied',
'emailsSendFailed',
'emailsSent',
'emailsUnsubscribed',
];
return events.map((event: string) => ({ name: (event === '*') ? '*' : capitalCase(event), value: event }));
}

View file

@ -12,6 +12,7 @@ import {
} from 'n8n-workflow';
import {
getEvents,
lemlistApiRequest,
} from './GenericFunctions';
@ -52,34 +53,7 @@ export class LemlistTrigger implements INodeType {
required: true,
default: '',
options: [
{
name: 'Email Bounced',
value: 'emailsBounced',
},
{
name: 'Email Clicked',
value: 'emailsClicked',
},
{
name: 'Email Opened',
value: 'emailsOpened',
},
{
name: 'Email Replied',
value: 'emailsReplied',
},
{
name: 'Email Send Failed',
value: 'emailsSendFailed',
},
{
name: 'Email Sent',
value: 'emailsSent',
},
{
name: 'Email Unsubscribed',
value: 'emailsUnsubscribed',
},
...getEvents(),
],
},
{
@ -144,8 +118,11 @@ export class LemlistTrigger implements INodeType {
const event = this.getNodeParameter('event') as string[];
const body: IDataObject = {
targetUrl: webhookUrl,
event,
type: event,
};
if (event.includes('*')) {
delete body.type;
}
Object.assign(body, options);
const webhook = await lemlistApiRequest.call(this, 'POST', '/hooks', body);
webhookData.webhookId = webhook._id;