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

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

46 lines
1 KiB
TypeScript
Raw Normal View History

import type {
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';
2020-10-21 14:30:07 -07:00
displayName = 'Pushover API';
documentationUrl = 'pushover';
properties: INodeProperties[] = [
2020-10-21 14:30:07 -07:00
{
displayName: 'API Key',
name: 'apiKey',
type: 'string',
typeOptions: { password: true },
2020-10-21 14:30:07 -07:00
default: '',
},
];
async authenticate(
credentials: ICredentialDataDecryptedObject,
requestOptions: IHttpRequestOptions,
): Promise<IHttpRequestOptions> {
if (requestOptions.method === 'GET' && requestOptions.qs) {
Object.assign(requestOptions.qs, { token: credentials.apiKey });
} else if (requestOptions.body) {
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
}