mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
⚡ Improvements
This commit is contained in:
@@ -4,8 +4,17 @@ import {
|
||||
ILoadOptionsFunctions,
|
||||
} from 'n8n-core';
|
||||
|
||||
import { OptionsWithUri } from 'request';
|
||||
import { IDataObject } from 'n8n-workflow';
|
||||
import {
|
||||
OptionsWithUri,
|
||||
} from 'request';
|
||||
|
||||
import {
|
||||
IDataObject,
|
||||
} from 'n8n-workflow';
|
||||
|
||||
import {
|
||||
get,
|
||||
} from 'lodash';
|
||||
|
||||
export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, body: object, query?: IDataObject): Promise<any> { // tslint:disable-line:no-any
|
||||
const credentials = this.getCredentials('customerIoApi');
|
||||
@@ -27,7 +36,6 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||
uri: `https://beta-api.customer.io/v1/api${endpoint}`,
|
||||
json: true,
|
||||
};
|
||||
console.log(options);
|
||||
try {
|
||||
return await this.helpers.request!(options);
|
||||
} catch (error) {
|
||||
@@ -46,3 +54,12 @@ export async function apiRequest(this: IHookFunctions | IExecuteFunctions | ILoa
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
|
||||
export function eventExists (currentEvents : string[], webhookEvents: IDataObject) {
|
||||
for (const currentEvent of currentEvents) {
|
||||
if (get(webhookEvents, `${currentEvent.split('.')[0]}.${currentEvent.split('.')[1]}`) !== true) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user