n8n/packages/nodes-base/credentials/PushoverApi.credentials.ts

37 lines
951 B
TypeScript
Raw Normal View History

2020-10-21 14:30:07 -07:00
import {
ICredentialDataDecryptedObject,
ICredentialTestRequest,
2020-10-21 14:30:07 -07:00
ICredentialType,
IHttpRequestOptions,
INodeProperties,
2020-10-21 14:30:07 -07:00
} from 'n8n-workflow';
export class PushoverApi implements ICredentialType {
name = 'pushoverApi';
displayName = 'Pushover API';
documentationUrl = 'pushover';
properties: INodeProperties[] = [
2020-10-21 14:30:07 -07:00
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
2020-10-21 14:30:07 -07:00
default: '',
},
];
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
}