mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-15 17:14:05 -08:00
479644a499
* ⚡ rule and fixes * ⚡ clean up
40 lines
891 B
TypeScript
40 lines
891 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,
|
|
// tslint:disable-next-line:no-any
|
|
body: any = {},
|
|
qs: IDataObject = {},
|
|
_option = {},
|
|
// tslint:disable-next-line:no-any
|
|
): 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);
|
|
}
|
|
}
|