2022-08-01 13:47:55 -07:00
|
|
|
import { IExecuteFunctions, IHookFunctions } from 'n8n-core';
|
2021-11-05 10:37:50 -07:00
|
|
|
|
2022-11-11 07:07:50 -08:00
|
|
|
import { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow';
|
2021-11-05 10:37:50 -07:00
|
|
|
|
2022-08-01 13:47:55 -07:00
|
|
|
import { OptionsWithUri } from 'request';
|
2021-11-05 10:37:50 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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;
|
|
|
|
}
|
|
|
|
|
2022-11-22 08:57:17 -08:00
|
|
|
return this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
|
2021-11-05 10:37:50 -07:00
|
|
|
}
|