mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-26 05:04:05 -08:00
76f9ad8bae
* Add credential injection and testing to Lemlist, Uproc, Supabase, Segment, Phantombuster, Mailgun and Dropcontact
39 lines
851 B
TypeScript
39 lines
851 B
TypeScript
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
|
|
|
|
import { IDataObject, ILoadOptionsFunctions, NodeApiError } from 'n8n-workflow';
|
|
|
|
import { OptionsWithUri } from 'request';
|
|
|
|
/**
|
|
* Make an authenticated API request to Bubble.
|
|
*/
|
|
export async function dropcontactApiRequest(
|
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
|
method: string,
|
|
endpoint: string,
|
|
body: IDataObject,
|
|
qs: IDataObject,
|
|
) {
|
|
const options: OptionsWithUri = {
|
|
method,
|
|
uri: `https://api.dropcontact.io${endpoint}`,
|
|
qs,
|
|
body,
|
|
json: true,
|
|
};
|
|
|
|
if (!Object.keys(body).length) {
|
|
delete options.body;
|
|
}
|
|
|
|
if (!Object.keys(qs).length) {
|
|
delete options.qs;
|
|
}
|
|
|
|
try {
|
|
return await this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
|
|
} catch (error) {
|
|
throw new NodeApiError(this.getNode(), error);
|
|
}
|
|
}
|