mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
9a1cc56806
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
43 lines
1 KiB
TypeScript
43 lines
1 KiB
TypeScript
import type {
|
|
IExecuteFunctions,
|
|
IHookFunctions,
|
|
ILoadOptionsFunctions,
|
|
IDataObject,
|
|
IHttpRequestOptions,
|
|
IHttpRequestMethods,
|
|
} from 'n8n-workflow';
|
|
|
|
export async function theHiveApiRequest(
|
|
this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions,
|
|
method: IHttpRequestMethods,
|
|
resource: string,
|
|
body: IDataObject | FormData = {},
|
|
query: IDataObject = {},
|
|
uri?: string,
|
|
option: IDataObject = {},
|
|
) {
|
|
const credentials = await this.getCredentials('theHiveProjectApi');
|
|
|
|
let options: IHttpRequestOptions = {
|
|
method,
|
|
qs: query,
|
|
url: uri || `${credentials.url}/api${resource}`,
|
|
body,
|
|
skipSslCertificateValidation: credentials.allowUnauthorizedCerts as boolean,
|
|
json: true,
|
|
};
|
|
|
|
if (Object.keys(option).length !== 0) {
|
|
options = Object.assign({}, options, option);
|
|
}
|
|
|
|
if (Object.keys(body).length === 0) {
|
|
delete options.body;
|
|
}
|
|
|
|
if (Object.keys(query).length === 0) {
|
|
delete options.qs;
|
|
}
|
|
return await this.helpers.requestWithAuthentication.call(this, 'theHiveProjectApi', options);
|
|
}
|