mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 00:54:06 -08:00
100d9bc087
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
47 lines
965 B
TypeScript
47 lines
965 B
TypeScript
import type {
|
|
IExecuteFunctions,
|
|
IHookFunctions,
|
|
IDataObject,
|
|
ILoadOptionsFunctions,
|
|
IPairedItemData,
|
|
IHttpRequestMethods,
|
|
IRequestOptions,
|
|
} from 'n8n-workflow';
|
|
|
|
/**
|
|
* Make an authenticated API request to Bubble.
|
|
*/
|
|
export async function dropcontactApiRequest(
|
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
|
method: IHttpRequestMethods,
|
|
endpoint: string,
|
|
body: IDataObject,
|
|
qs: IDataObject,
|
|
) {
|
|
const options: IRequestOptions = {
|
|
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;
|
|
}
|
|
|
|
return await this.helpers.requestWithAuthentication.call(this, 'dropcontactApi', options);
|
|
}
|
|
|
|
export function mapPairedItemsFrom<T>(iterable: Iterable<T> | ArrayLike<T>): IPairedItemData[] {
|
|
return Array.from(iterable, (_, i) => i).map((index) => {
|
|
return {
|
|
item: index,
|
|
};
|
|
});
|
|
}
|