mirror of
https://github.com/n8n-io/n8n.git
synced 2024-11-14 00:24:07 -08:00
59 lines
1.1 KiB
TypeScript
59 lines
1.1 KiB
TypeScript
|
import {
|
||
|
IAuthenticateGeneric,
|
||
|
ICredentialDataDecryptedObject,
|
||
|
ICredentialTestRequest,
|
||
|
ICredentialType,
|
||
|
IHttpRequestOptions,
|
||
|
INodeProperties,
|
||
|
NodePropertyTypes,
|
||
|
} from 'n8n-workflow';
|
||
|
|
||
|
export class WhatsAppApi implements ICredentialType {
|
||
|
name = 'whatsAppApi';
|
||
|
displayName = 'WhatsApp API';
|
||
|
documentationUrl = 'whatsApp';
|
||
|
properties: INodeProperties[] = [
|
||
|
{
|
||
|
displayName: 'Access Token',
|
||
|
type: 'string',
|
||
|
name: 'accessToken',
|
||
|
default: '',
|
||
|
required: true,
|
||
|
},
|
||
|
{
|
||
|
displayName: 'Bussiness Account ID',
|
||
|
type: 'string',
|
||
|
name: 'businessAccountId',
|
||
|
default: '',
|
||
|
required: true,
|
||
|
},
|
||
|
];
|
||
|
|
||
|
authenticate: IAuthenticateGeneric = {
|
||
|
type: 'generic',
|
||
|
properties: {
|
||
|
headers: {
|
||
|
Authorization: '=Bearer {{$credentials.accessToken}}',
|
||
|
},
|
||
|
},
|
||
|
};
|
||
|
|
||
|
test: ICredentialTestRequest = {
|
||
|
request: {
|
||
|
baseURL: 'https://graph.facebook.com/v13.0',
|
||
|
url: '/',
|
||
|
ignoreHttpStatusErrors: true,
|
||
|
},
|
||
|
rules: [
|
||
|
{
|
||
|
type: 'responseSuccessBody',
|
||
|
properties: {
|
||
|
key: 'error.type',
|
||
|
value: 'OAuthException',
|
||
|
message: 'Invalid access token',
|
||
|
},
|
||
|
},
|
||
|
],
|
||
|
};
|
||
|
}
|