2020-10-21 14:30:07 -07:00
|
|
|
import {
|
2022-05-07 04:25:53 -07:00
|
|
|
ICredentialDataDecryptedObject,
|
|
|
|
ICredentialTestRequest,
|
2020-10-21 14:30:07 -07:00
|
|
|
ICredentialType,
|
2022-05-07 04:25:53 -07:00
|
|
|
IHttpRequestOptions,
|
2021-06-12 09:39:55 -07:00
|
|
|
INodeProperties,
|
2020-10-21 14:30:07 -07:00
|
|
|
} from 'n8n-workflow';
|
|
|
|
|
|
|
|
export class PushoverApi implements ICredentialType {
|
|
|
|
name = 'pushoverApi';
|
|
|
|
displayName = 'Pushover API';
|
2020-10-27 02:21:58 -07:00
|
|
|
documentationUrl = 'pushover';
|
2021-06-12 09:39:55 -07:00
|
|
|
properties: INodeProperties[] = [
|
2020-10-21 14:30:07 -07:00
|
|
|
{
|
|
|
|
displayName: 'API Key',
|
|
|
|
name: 'apiKey',
|
2021-06-12 09:39:55 -07:00
|
|
|
type: 'string',
|
2020-10-21 14:30:07 -07:00
|
|
|
default: '',
|
|
|
|
},
|
|
|
|
];
|
2022-05-07 04:25:53 -07:00
|
|
|
async authenticate(credentials: ICredentialDataDecryptedObject, requestOptions: IHttpRequestOptions): Promise<IHttpRequestOptions> {
|
|
|
|
if (requestOptions.method === 'GET') {
|
|
|
|
Object.assign(requestOptions.qs, { token: credentials.apiKey });
|
|
|
|
} else {
|
|
|
|
Object.assign(requestOptions.body, { token: credentials.apiKey });
|
|
|
|
}
|
|
|
|
return requestOptions;
|
|
|
|
}
|
|
|
|
test: ICredentialTestRequest = {
|
|
|
|
request: {
|
|
|
|
baseURL: 'https://api.pushover.net/1',
|
|
|
|
url: '=/licenses.json?token={{$credentials?.apiKey}}',
|
|
|
|
method: 'GET',
|
|
|
|
},
|
|
|
|
};
|
2020-10-21 14:30:07 -07:00
|
|
|
}
|