feat(Pushover Node): Add 'HTML Formatting' option and credential test (#3082)

* Add html additional field

https://pushover.net/api#html

*  replaced input type to boolean, added credential test

*  credentials and linter fixes

*  Improvements

*  Fix description

Co-authored-by: Michael Kret <michael.k@radency.com>
Co-authored-by: ricardo <ricardoespinoza105@gmail.com>
This commit is contained in:
Albert Kiskorov
2022-05-07 18:25:53 +07:00
committed by GitHub
parent 63b6c9f128
commit b3dc6d9d9c
5 changed files with 59 additions and 21 deletions

View File

@@ -9,32 +9,28 @@ import {
} from 'n8n-core';
import {
IDataObject, NodeApiError,
IDataObject, IHttpRequestMethods, IHttpRequestOptions, NodeApiError,
} from 'n8n-workflow';
export async function pushoverApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise<any> { // tslint:disable-line:no-any
export async function pushoverApiRequest(this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: IHttpRequestMethods, path: string, body: any = {}, qs: IDataObject = {}, option = {}): Promise<any> { // tslint:disable-line:no-any
const credentials = await this.getCredentials('pushoverApi');
if (method === 'GET') {
qs.token = credentials.apiKey;
} else {
body.token = credentials.apiKey as string;
}
const options: OptionsWithUri = {
const options: IHttpRequestOptions = {
headers: {
'Content-Type': 'multipart/form-data',
},
method,
formData: body,
body,
qs,
uri: `https://api.pushover.net/1${path}`,
url: `https://api.pushover.net/1${path}`,
json: true,
};
try {
if (Object.keys(body).length === 0) {
delete options.body;
}
//@ts-ignore
return await this.helpers.request.call(this, options);
return await this.helpers.requestWithAuthentication.call(this, 'pushoverApi', options);
} catch (error) {
throw new NodeApiError(this.getNode(), error);
}