n8n/packages/nodes-base/nodes/Sendy/GenericFunctions.ts
Iván Ovejero cfd32d2642
refactor: Phase out TSLint in nodes-base (no-changelog) (#4798)
* 🔥 Remove TSLint scripts

* 🔥 Remove TSLint config

* 🔥 Remove TSLint exceptions

* 👕 Adjust lint config

* ✏️ Add story numbers
2022-12-02 15:25:21 +01:00

39 lines
820 B
TypeScript

import { OptionsWithUri } from 'request';
import { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core';
import { IDataObject, NodeApiError } from 'n8n-workflow';
export async function sendyApiRequest(
this: IExecuteFunctions | ILoadOptionsFunctions,
method: string,
path: string,
body: any = {},
qs: IDataObject = {},
_option = {},
): Promise<any> {
const credentials = await this.getCredentials('sendyApi');
body.api_key = credentials.apiKey;
body.boolean = true;
const options: OptionsWithUri = {
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
},
method,
form: body,
qs,
uri: `${credentials.url}${path}`,
};
try {
//@ts-ignore
return await this.helpers.request.call(this, options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}
}