mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-10 14:44:05 -08:00
🔀 Merge branch 'master' of github.com:n8n-io/n8n
This commit is contained in:
commit
a26d8f38cd
|
@ -13,6 +13,10 @@ import {
|
||||||
OptionsWithUri,
|
OptionsWithUri,
|
||||||
} from 'request';
|
} from 'request';
|
||||||
|
|
||||||
|
import {
|
||||||
|
capitalCase,
|
||||||
|
} from 'change-case';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make an authenticated API request to Lemlist.
|
* Make an authenticated API request to Lemlist.
|
||||||
*/
|
*/
|
||||||
|
@ -87,3 +91,22 @@ export async function lemlistApiRequestAllItems(
|
||||||
);
|
);
|
||||||
return returnData;
|
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';
|
} from 'n8n-workflow';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
getEvents,
|
||||||
lemlistApiRequest,
|
lemlistApiRequest,
|
||||||
} from './GenericFunctions';
|
} from './GenericFunctions';
|
||||||
|
|
||||||
|
@ -52,34 +53,7 @@ export class LemlistTrigger implements INodeType {
|
||||||
required: true,
|
required: true,
|
||||||
default: '',
|
default: '',
|
||||||
options: [
|
options: [
|
||||||
{
|
...getEvents(),
|
||||||
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',
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -144,8 +118,11 @@ export class LemlistTrigger implements INodeType {
|
||||||
const event = this.getNodeParameter('event') as string[];
|
const event = this.getNodeParameter('event') as string[];
|
||||||
const body: IDataObject = {
|
const body: IDataObject = {
|
||||||
targetUrl: webhookUrl,
|
targetUrl: webhookUrl,
|
||||||
event,
|
type: event,
|
||||||
};
|
};
|
||||||
|
if (event.includes('*')) {
|
||||||
|
delete body.type;
|
||||||
|
}
|
||||||
Object.assign(body, options);
|
Object.assign(body, options);
|
||||||
const webhook = await lemlistApiRequest.call(this, 'POST', '/hooks', body);
|
const webhook = await lemlistApiRequest.call(this, 'POST', '/hooks', body);
|
||||||
webhookData.webhookId = webhook._id;
|
webhookData.webhookId = webhook._id;
|
||||||
|
|
Loading…
Reference in a new issue