mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-23 11:44:06 -08:00
🔀 Merge branch 'master' of github.com:n8n-io/n8n
This commit is contained in:
commit
a26d8f38cd
|
@ -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 }));
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue